|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #27643 include behavior (revisit #11326 and #9673)
Submitted: 2004-03-18 20:07 UTC Modified: 2012-04-14 03:01 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: schapht at drexel dot edu Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 4.3.4 OS: Mac OS 10.3.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: schapht at drexel dot edu
New email:
PHP Version: OS:


 [2004-03-18 20:07 UTC] schapht at drexel dot edu
Php 4.3.4 still has this the issue reported in bugs 
#11326 and #9673.  Even though #11326 lists it as fixed 
in (CVS/4.0.7).

Did the behavior change again?  Is there a switch 
somewhere I'm missing?

If not, would it be possible to add a switch (or another 
function) so that includes could be based on the file 
calling the include?

Reproduce code:
//index.php in ./
$a = new A();
echo $a->printer();

//A.class.php in ./include
class A {
  function printer() {
    $b = new B();
    return $b->printer();

//B.class.php in ./include
class B {
  function printer() {
    return "did it work?";

Expected result:
did it work?

Actual result:
Warning: main(./B.class.php): failed to open stream: No 
such file or directory in /Users/schapht/Sites/test/
include/A.class.php on line 3

Warning: main(): Failed opening './B.class.php' for 
inclusion (include_path='.:/usr/local/lib/php') in /
Users/schapht/Sites/test/include/A.class.php on line 3

Fatal error: Cannot instantiate non-existent class: b in 
/Users/schapht/Sites/test/include/A.class.php on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-18 17:01 UTC] clarkke8 at yahoo dot com
Still seeing this issue in 5.2. Very annoying. Ideally the include functions 
(include, include_once, require, require_once) would not use the current working 
directory, but rather the value of dirname(__FILE__) when looking for an included 
 [2012-04-13 20:55 UTC]
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 [2012-04-13 20:55 UTC]
./ is relative to the current working directory, which for most SAPIs is the originally called script (namely index.php).

This cannot be changed in any case, due to BC concerns. If you want to include files relative to the containing directory use __DIR__ . '/xyz.php'.
 [2012-04-14 03:01 UTC]
-Status: Closed +Status: Wont fix -Assigned To: nikic +Assigned To:
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Apr 21 18:01:26 2019 UTC