#24822 [Opn]: order of function scope searching doesn't match docs
| From: | stas@php.net | Date: | Sun, 27 Jul 2003 13:50:59 +0000 |
| Subject: | #24822 [Opn]: order of function scope searching doesn't match docs | ||
| References: | 1 | Groups: | php.mirrors |
| Request: | Send a blank email to php-mirrors+get-19577@lists.php.net to get a copy of this message | ||
ID: 24822
Updated by: stas@php.net
Reported By: norny at yahoo dot com
Status: Open
-Bug Type: Zend Engine 2 problem
+Bug Type: Website problem
Operating System: Windows XP
PHP Version: 5CVS-2003-07-26 (dev)
New Comment:
The text is out of date. Namespaces are officially dead for now.
Previous Comments:
------------------------------------------------------------------------
[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