Re: Re: Include problems
| From: | Ernest E Vogelsinger | Date: | Sun, 04 May 2003 09:25:42 +0000 |
| Subject: | Re: Re: Include problems | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146336@lists.php.net to get a copy of this message | ||
At 21:09 03.05.2003, Shawn McKenzie said:
--------------------[snip]--------------------
>I understand what's being said that . is the current dir, but shouldn't PHP
>look in the dir returned by dirname(__FILE__) before it looks in the include
>path???
--------------------[snip]--------------------
As long as a script doesn't chdir() to another directory you're located in
the directory where the initial script os located (usually the webserver's
DOCROOT, plus any additional tree branch from the URL.
Assuming DOCROOT is /var/www:
http://dom/script.php /var/www/script.php
http://dom/sub/script.php /var/www/sub/script.php
This doesn't change for included scripts, regardless where they are
located. You always need to include a script either absolute from the hosts
root directory (e.g. '/var/www/tools/scripts/helper.inc'), or relative from
your starting point.
For a more complex layout it might be a good idea to have a config file
defining the locations and being included at the very top of any
application. Thus you can use symbolic path names for inclusion, and don't
have too much hassle when redesigning your directory layout.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/