php的文件中,它说:如何从孩子获得父母重写的财产?
范围解析操作符(也称为Paamayim Nekudotayim)或 简单来说,双结肠,是一个令牌,允许 静态,常量和覆盖接入属性或一类的方法。
我得到一个错误,当我尝试访问覆盖的(而不是静态)父属性:
class foo
{
public $bar = 'foobar';
}
class baz extends foo
{
public $bar = 'bazbar';
public function get_bar()
{
echo parent::$bar; //Fatal error: Access to undeclared static property: foo::$bar
}
}
$baz = new baz;
$baz->get_bar();
$ this-> bar from the child will give you bazbar,not foobar –