class Foo {
public static function foobar() {
self::whereami();
}
protected static function whereami() {
echo 'foo';
}
}
class Bar extends Foo {
protected static function whereami() {
echo 'bar';
}
}
Foo::foobar();
Bar::foobar();
預期的結果foobar
實際結果foofoo
擴展在PHP
更糟糕的是靜態方法,服務器被限制在PHP 5.2
PHP 5.3引入了[後期靜態綁定](http://php.net/manual/en/language.oop5.late-static-bindings.php)。看起來你可能會運氣不好,5.2 – Phil 2011-05-02 04:10:12