2012-02-01 2 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; 
} 
관련 문제