note 27194 deleted from function.include by sniper
| From: | sniper@php.net | Date: | Tue, 04 Nov 2003 00:40:52 +0000 |
| Subject: | note 27194 deleted from function.include by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59779@lists.php.net to get a copy of this message | ||
Note Submitter: ivo@i7.nl
----
In PHP 4.1.0 there has been a slight modification to the way include works with paths. This
modification makes some of the above comments obsolete, so I'm sharing this here (the only
place you could have noticed it is in the changelog. I think it should also be mentioned in the docs
of include).
This is what changed:
Say you've got a script in docroot/ called test.php, which does the following:
include "somesubdir/test.inc";
Suppose test.inc in turn does the following:
include "subinclude.inc";
In the old days, subinclude.inc had to reside in docroot/, because the path from which files were
included was the same as the dir in which the script executes.
As of PHP 4.1.0, subinclude.inc can either be in docroot/ or in docroot/somesubdir. include() will
give preference to the one in docroot. Only if that one doesn't exist, it will include the one
from docroot/somesubdir.
This could lead to strange behaviour. (For example I released a version of my open source project
Achievo that worked perfectly on my server but failed on a lot of people's setup, because I
inadvertently relied on this include feature without knowing it (I had a wrong include which turned
out fine because of this change).
Greetings,
Ivo