note 69766 added to language.oop5.static
| From: | (dot) | Date: | Wed, 20 Sep 2006 06:42:40 +0000 |
| Subject: | note 69766 added to language.oop5.static | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117338@lists.php.net to get a copy of this message | ||
This reacts to comment from
michael at digitalgnosis dot removethis dot com from 16-Dec-2004 08:09
> Note that Base::Foo() may no longer be declared 'static' since static methods cannot
> be overridden (this means it will trigger errors if error level includes E_STRICT.)
In my test on Windows PHP Version 5.1.4 it seems that it *is possible* to override static method.
This code works at my machine without producing E_STRICT error:
<?php
class Base
{
static function Foo ( $class = __CLASS__ )
{
call_user_func(array($class,'Bar'));
}
}
class Derived extends Base
{
static function Foo ( $class = __CLASS__ )
{
parent::Foo($class);
}
static function Bar ()
{
echo "Derived::Bar()";
}
}
Derived::Foo(); // This time it works.
?>
----
Server IP: 147.32.160.17
Probable Submitter: 217.11.230.42
----
Manual Page -- http://www.php.net/manual/en/language.oop5.static.php
Edit -- https://master.php.net/note/edit/69766
Del: integrated -- https://master.php.net/note/delete/69766/integrated
Del: useless -- https://master.php.net/note/delete/69766/useless
Del: bad code -- https://master.php.net/note/delete/69766/bad+code
Del: spam -- https://master.php.net/note/delete/69766/spam
Del: non-english -- https://master.php.net/note/delete/69766/non-english
Del: in docs -- https://master.php.net/note/delete/69766/in+docs
Del: other reasons-- https://master.php.net/note/delete/69766
Reject -- https://master.php.net/note/reject/69766
Search -- https://master.php.net/manage/user-notes.php