我有关于在另一个类中调用一个类的静态属性的问题。
Class A {
public $property;
public function __construct( $prop ) {
$this->property = $prop;
}
public function returnValue(){
return static::$this->property;
}
}
Class B extends A {
public static $property_one = 'This is first property';
public static $property_two = 'This is second property';
}
$B = new B( 'property_one' );
$B->returnValue();
我希望返回This is first property
但输出只是 __construct 中的参数输入名称;
当我print_r( static::$this->property );
的输出只是property_one