note 56345 added to language.oop5.static
| From: | cbelin at free dot fr | Date: | Wed, 31 Aug 2005 09:47:08 +0000 |
| Subject: | note 56345 added to language.oop5.static | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94485@lists.php.net to get a copy of this message | ||
Manual says that static members and methods cannot be redefined in subclasses.
It seems that it's not completely true (at least with PHP 5.0.4 under Windows XP), as
redefining static methods in subclasses is allowed, and works fine (i.e. without triggering errors
even if error level includes E_STRICT).
Here is an example :
class Base
{
public static function foo()
{
return 'Foo...';
}
}
class Extended extends Base
{
public static function foo()
{
return 'Bar !!!';
}
}
echo Extended::foo();
// this prints 'Bar !!!' instead of 'Foo...'
----
Manual Page -- http://www.php.net/manual/en/language.oop5.static.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56345
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56345&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56345&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56345&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56345&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56345&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56345&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56345&report=yes
Search -- http://master.php.net/manage/user-notes.php