note 49541 added to language.oop5.paamayim-nekudotayim
| From: | ianat | Date: | Tue, 01 Feb 2005 06:43:13 +0000 |
| Subject: | note 49541 added to language.oop5.paamayim-nekudotayim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84303@lists.php.net to get a copy of this message | ||
Please note that methods called by the scope resolution operator which are defined by a superclass
of the first operand are called in the scope of the SUPERCLASS. For example,
<?php
class ExampleSuperclass
{
static function classType()
{
return "superclass";
}
static function doSomething()
{
echo "doing something with " . self::classType();
}
}
class ExampleClass extends ExampleSuperclass
{
static function classType()
{
return "subclass";
}
}
ExampleClass::doSomething();
// output is "doing something with superclass"!
?>
This can be surprising (it surprised me!) when coming from other object-oriented languages, which
would output "doing something with subclass" in this case.
----
Manual Page -- http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49541
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49541&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49541&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49541&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49541&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49541&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49541&report=yes
Search -- http://master.php.net/manage/user-notes.php