php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
14 + 25 = ?
Subscribe to this entry?

 
 [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';
        }
}
?>

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.)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-10 15:51 UTC] jimw@php.net
putting "var $name" inside a function doesn't define it inside the class.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 21:01:31 2024 UTC