ID: 26174 Updated by: [EMAIL PROTECTED] Reported By: myle34 at hotmail dot com -Status: Open +Status: Bogus Bug Type: Variables related Operating System: Windows XP Home PHP Version: 5.0.0b2 (beta2) New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php when you include a file within a function/method , the global code is in the function/method scope. therefore $foo is in the function scope... (not global).. functions/classes/methods you define in there however are defined globaly.. Previous Comments: ------------------------------------------------------------------------ [2003-11-08 02:30:56] myle34 at hotmail dot com Description: ------------ This is related to Bug #26173 (http://bugs.php.net/bug.php?id=26173) but the reproduce code was wrong. I am using Windows XP Home and Apache 2.0.47 with PHP beta 2. This bug is related to function/class/global scopes. Note that if you merge foo.php and bar.php (foo.php and right after that bar.php) (ie. without the include_once), this will work as expected! I haven't tested this with include but I suspect it would have the same problem. Reproduce code: --------------- // foo.php <?php class TestOne { function __construct() { include_once 'bar.php'; } } $TestOne = new TestOne(); ?> // bar.php <?php // uncommenting this makes it work // global $foo; $foo = 'bar'; // uncommenting this does nothing // global $foo; function TestTwo() { global $foo; echo $foo; } Tesl'><(); ?> Expected result: ---------------- bar Actual result: -------------- No output ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26174&edit=1
