#37847 [Opn->Bgs]: require_once does not include files with same name,but are in other locations

From: Date: Mon, 19 Jun 2006 12:29:54 +0000
Subject: #37847 [Opn->Bgs]: require_once does not include files with same name,but are in other locations
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-98487@lists.php.net to get a copy of this message
ID: 37847 User updated by: rblanker at xs4all dot nl Reported By: rblanker at xs4all dot nl -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux Fedora 4 PHP Version: 5.1.4 New Comment: Hmm I now see that the problem is that its included from the path of the /index.php and it does not include from the included file. The new output will show; this is /index.php this is /bug/index.php this is toinclude.php Previous Comments: ------------------------------------------------------------------------ [2006-06-19 12:27:20] rblanker at xs4all dot nl Btw; if change /index.php into /index.php: <? print "this is /index.php\n"; //require_once("toinclude.php"); removed. require_once("bug/index.php"); ?> The new output will show; this is /index.php this is /bug/index.php this is /bug/toinclude.php ------------------------------------------------------------------------ [2006-06-19 12:24:23] rblanker at xs4all dot nl Description: ------------ require_once() (probably include_once() too, haven't tested) does not include files in 2 different directories when both files have the same filename (but are 2 different files in 2 different paths); require_once() stores what is given and skips any require_once() with the same input, not matter what the location is where require_once() was called. It should store/compare the complete path of the included file, not the input. The workaround is now by specifing the whole path; require_once($_SERVER["DOCUMENT_ROOT"] . "/toinclude.php"); Reproduce code: --------------- create 4 files; /index.php: <? print "this is /index.php\n"; require_once("toinclude.php"); require_once("bug/index.php"); ?> /toinclude.php: <? print "this is /toinclude.php\n"; ?> /bug/index.php; <? print "this is /bug/index.php\n"; require_once("toinclude.php"); ?> /bug/toinclude.php; <? print "this is /bug/toinclude.php\n"; ?> Now call '/index.php' Expected result: ---------------- this is /index.php this is /toinclude.php this is /bug/index.php this is /bug/toinclude.php Actual result: -------------- this is /index.php this is /toinclude.php this is /bug/index.php ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37847&edit=1

« previous php.bugs (#98487) next »