2012-02-01 51 views
2
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。 为什么?抽象静态属性不能被覆盖?

回答

1

“自我”是由当前类使用, 如果你想获得孩子的静态属性,用“静”为:

final public static function __callStatic($method, $args = array()) { 
    echo **static**::$var; 
}