At 03:05 PM 12/22/02 +0000, z z wrote:

__FILE__ is useful to know the current script's path
__FILE__ is a 'constant' defined by the Zend Engine that tells you the name of the current file. If you are in an Include the name of the included file is returned, if you are in the main file its name is returned. This is commonly used in creating error messages.

> What is the cleanest and self-contained way to do a
> relative include from an included file which might
> not be in the same directory as its parent?

Put the files in a directory named in the include_path such that you don't have to mess with any kind of path information within the programs. That's what it is there for.

If you have to move the include files which would you rather do:

a) change the include_path in php.ini, httpd.conf, or .htaccess.

b) edit every file in the project to change the path.


I have a group of common include files most of my sites use, and another group of files for each domain. The include path for each web sites is set in the webserver configuration, and looks like this:

<VirtualHost www.somedomain.com>
...
php_value include_path /web/lib:/web/hosts/www.somedomain.com/lib:.
</VirtualHost>


You can group files into directories under the include_path to keep related include files together.

include( 'category/program.inc' );

will search every directory in the include path for a subdirectory named 'category' containing a file 'program.inc' to include. Very handy!


Rick


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to