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