abstract class Ghost {
protected static $var = 'I\'m a ghost';
final public static function __callStatic($method, $args = array()) {
echo self::$var;
}
}
class Person extends Ghost {
protected static $var = 'I\'m a person';
}
Person::whatever()
的调用将打印:I'm a ghost
。
为什么?
最佳答案
您正在寻找名为 Late Static Binding 的东西, 这需要 PHP 5.3+
关于php - 抽象静态属性不能被覆盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9092902/