php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24992 nested require() not working, no error given
Submitted: 2003-08-08 20:10 UTC Modified: 2003-08-08 20:36 UTC
From: davey@php.net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.3RC3 OS: WinXP Pro SP1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: davey@php.net
New email:
PHP Version: OS:

 

 [2003-08-08 20:10 UTC] davey@php.net
Description:
------------
This is kinda hard to explain, but here goes.
I have this directory structure:

/
/htdocs
/includes

I have a file in /htdocs (index.php) which includes a file (base.class.php) in /includes which in turn includes another file (config.inc.php) in /includes.

/includes is in my include_path and so I'm just using:

require('file');

Now, the problem seems to be that the variable in config.inc.php (its just a single array of config options) is not visible in base.class.php unless I use a relative path (require('../includes/config.inc.php');)

As I say there is no problem when using the relative path and no Fatal Error if I'm not, just the Notice.

I haven't had time to come up with a test case (sorry) but if this is indeed a proper bug I felt you might like to fix it before 4.3.3 final is out. I can also confirm this behavior in a snap (4.3.x 200308050430) and 4.3.2 final.

I will come up with a test case and also test on FBSD asap (next couple of days is my earliest)

Note: there seems to be no problems when there is no nested inclusion involved (i.e. index.php requires footer.inc.php and can access its vars)


- Davey

Reproduce code:
---------------
class base {
    function base() {
        require('config.inc.php');
        $this->_CONFIG = $_CONFIG;
    }
}

Expected result:
----------------
$_CONFIG should be assigned to $this->config

Actual result:
--------------
Notice: Undefined variable: _CONFIG

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-08 20:36 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Works fine with 4.3.2 and latest CVS. You're just doing something wrong. Please ask support questions elsewhere.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 26 19:01:30 2024 UTC