|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-06-19 12:24 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 19 10:00:01 2025 UTC |
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