#24822 [Opn->Csd]: order of function scope searching doesn't match docs

From: Date: Mon, 28 Jul 2003 08:39:06 +0000
Subject: #24822 [Opn->Csd]: order of function scope searching doesn't match docs
References: 1  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-19594@lists.php.net to get a copy of this message
ID: 24822 Updated by: goba@php.net Reported By: norny at yahoo dot com -Status: Open +Status: Closed Bug Type: Website problem Operating System: Windows XP PHP Version: 5CVS-2003-07-26 (dev) New Comment: Out of date text removed from site, now it redirects to the more up to date zend-engine-2.php file. Previous Comments: ------------------------------------------------------------------------ [2003-07-27 08:50:57] stas@php.net The text is out of date. Namespaces are officially dead for now. ------------------------------------------------------------------------ [2003-07-26 17:09:43] norny at yahoo dot com 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 this bug report at http://bugs.php.net/?id=24822&edit=1

« previous php.mirrors (#19594) next »