From: tonerzhang at hotmail dot com Operating system: windows2000 server sp4 PHP version: 4.3.8 PHP Bug Type: Feature/Change Request Bug description: can't get values from a class's method when include this class that use global
Description: ------------ Hello, Excuse my too poor english! question: can't get values from a class's method when include this class that use global variable. please run the exemple:test1.php and exemple:test2.php why? exemple: test1.php <?php function showVar() { include 'class_test.php'; $obc = new testClass(); $obc->showVar(); } showVar(); ?> test2.php <?php include 'class_test.php'; function showVar() { $obc = new testClass(); $obc->showVar(); } showVar(); ?> class_test.php <?php $tmpVar = "test data"; class testClass { function showVar() { global $tmpVar; var_dump($tmpVar); } } ?> Reproduce code: --------------- class_test.php <?php $tmpVar = "test data"; class testClass { function showVar() { global $tmpVar; var_dump($tmpVar); } } ?> test1.php <?php function showVar() { include 'class_test.php'; $obc = new testClass(); $obc->showVar(); } showVar(); ?> Expected result: ---------------- string:"test data" Actual result: -------------- NULL -- Edit bug report at http://bugs.php.net/?id=30418&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30418&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30418&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30418&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30418&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30418&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30418&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30418&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30418&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30418&r=support Expected behavior: http://bugs.php.net/fix.php?id=30418&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30418&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30418&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30418&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30418&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30418&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30418&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30418&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30418&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30418&r=mysqlcfg