note 71446 added to function.include
| From: | sean dot farrell at digital-egg dot org | Date: | Wed, 29 Nov 2006 14:12:17 +0000 |
| Subject: | note 71446 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120160@lists.php.net to get a copy of this message | ||
The way PHP handles the ./ and ../ is totally counter intuitive. As said if the included file is
preceded by a ./ and ../ it looked up from the current working directory. And that is defined by the
of the EXECUTED script. That is the script that you specified in the url.
So if your have a.php that includes include/b.php that includes ../extern/c.php, it will not do what
you want. You can use extern/c.php instead if you never execute outside of the document root. For me
that just will not cut it. Since I execute test suites if files are directly called, like in python.
Here is my dirty trick that works, since I only have two levels of file hierarchy:
set_include_path("../:./");
require_once("extern/c.php");
And here is an open question: Why are the included files not looked up relative from the file that
includes them and then in the include path? This would be a behavior like in all other languages.
----
Server IP: 217.13.201.10
Probable Submitter: 85.180.86.83
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- https://master.php.net/note/edit/71446
Del: integrated -- https://master.php.net/note/delete/71446/integrated
Del: useless -- https://master.php.net/note/delete/71446/useless
Del: bad code -- https://master.php.net/note/delete/71446/bad+code
Del: spam -- https://master.php.net/note/delete/71446/spam
Del: non-english -- https://master.php.net/note/delete/71446/non-english
Del: in docs -- https://master.php.net/note/delete/71446/in+docs
Del: other reasons-- https://master.php.net/note/delete/71446
Reject -- https://master.php.net/note/reject/71446
Search -- https://master.php.net/manage/user-notes.php