From: norny at yahoo dot com Operating system: Windows XP PHP version: 5CVS-2003-07-26 (dev) PHP Bug Type: Zend Engine 2 problem Bug description: order of function scope searching doesn't match docs
Description: ------------ According to http://www.php.net/ZEND_CHANGES.txt, "WIth both constants and functions, if you don't specify a class context the current class will be searched first and if the search fails then the global scope will be searched. If you want to force PHP to only check the global scope you can use the main:: accessor." The snap I just downloaded seems to be search global first then the class second. Main:: doesn't seem to exist. Reproduce code: --------------- <?php function asdf() { echo 'global'; } class FooClass { function asdf() { echo 'class'; } function printFoo() { asdf(); // outputs 'global' self::asdf(); // outputs 'class' main::asdf(); // Fatal error: Class 'main' not found in C:\Apache2\htdocs\test.php on line 14 } } $qwerty = new FooClass; $qwerty->printFoo(); ?> Expected result: ---------------- The first call to asdf() in printFoo should produce 'class'. The second self::asdf() seems to be correct, and the main::asdf() should print 'global' Actual result: -------------- The first call to asdf() in printFoo() should print 'class', not 'global'. The main:: accessor doesn't seem to be known but ZEND_CHANGES.txt says it does exist. -- Edit bug report at http://bugs.php.net/?id=24822&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24822&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24822&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=24822&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24822&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24822&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24822&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24822&r=support Expected behavior: http://bugs.php.net/fix.php?id=24822&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24822&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24822&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24822&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24822&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24822&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24822&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24822&r=gnused