note 69766 deleted from language.oop5.static by cmb
| From: | cmb@php.net | Date: | Sun, 01 Sep 2019 07:38:54 +0000 |
| Subject: | note 69766 deleted from language.oop5.static by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212063@lists.php.net to get a copy of this message | ||
Note Submitter: jan(dot)-re-mov.ethis-mazanek/AT-abeo.cz
----
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.
?>