|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2136 require/include parsing error
Submitted: 1999-08-23 18:59 UTC Modified: 2001-02-10 15:51 UTC
From: kamee at methadonia dot net Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0.12 OS: openbsd
Private report: No CVE-ID: None
 [1999-08-23 18:59 UTC] kamee at methadonia dot net
i have noticed a problem with the following php code is ran...

class foo {
        function foo {
                require 'settings.php';

var $foo_variable = 100;

the problem seems that when you include/require a file within a class constructor any variables that are initialized within the included file are not accessible o
utside of the included php file (ie. i cannot use foo_variable later within the class foo.) I think this is caused because when the file settings.php is parsed it doesnt consider the variable eligible for the 'var' addition because of its lack of being within the function declaration (even though it really is.)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-10 15:51 UTC]
putting "var $name" inside a function doesn't define it inside the class.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Dec 06 17:01:27 2023 UTC