Bug #12622 Updated: scope of $this and static functions
| From: | sniper@php.net | Date: | Mon, 22 Oct 2001 00:10:48 +0000 |
| Subject: | Bug #12622 Updated: scope of $this and static functions | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-68664@lists.php.net to get a copy of this message | ||
ID: 12622
Updated by: sniper
Reported By: jh@synergy.cx
Old Status: Open
Status: Analyzed
Bug Type: Class/Object related
Operating System: linux 2.2
PHP Version: 4.0.6
New Comment:
Reproduced with PHP 4.1.0RC1.
Here is better example script (static is reserverd keyword):
<?php
class blaah
{
function method()
{
echo get_class($this);
}
}
class Container
{
function Container()
{
blaah::method();
}
}
$Container = new Container();
?>
Previous Comments:
------------------------------------------------------------------------
[2001-08-07 11:00:57] jh@synergy.cx
When calling a static function from within another
class the $this - reference is not empty, but it points
to the class in which you call the static function. To
illustrate:
class Static
{ function method()
{ echo get_class($this);
}
}
class Container
{ function Container()
{ Static::method();
}
}
$Container = new Container();
The output is "Container", but there shouldn't be a reference, because it's not
anymore the scope of the
reference.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=12622&edit=1