note 27194 added to function.include

From: Date: Tue, 26 Nov 2002 19:56:07 +0000
Subject: note 27194 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-40008@lists.php.net to get a copy of this message
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 -- http://www.php.net/manual/en/function.include.php http://master.php.net/manage/user-notes.php?action=edit+27194 http://master.php.net/manage/user-notes.php?action=delete+27194 http://master.php.net/manage/user-notes.php?action=reject+27194

« previous php.notes (#40008) next »