From: myle34 at hotmail dot com Operating system: Windows XP Home PHP version: 5.0.0b2 (beta2) PHP Bug Type: Variables related Bug description: Global vs. class vs. variable scope w/ include
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 bug report at http://bugs.php.net/?id=26174&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26174&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26174&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26174&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26174&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26174&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=26174&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26174&r=support Expected behavior: http://bugs.php.net/fix.php?id=26174&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26174&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26174&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26174&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26174&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26174&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26174&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26174&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26174&r=float
