Home > Article > Backend Development > 基础题:关于parent子类属性?解决方案
基础题::关于parent子类属性?
class a{<br /> <br /> public $name="a";<br /> <br /> public function test1()<br /> {<br /> echo $this->name;<br /> }<br /> }<br /> <br /> class b extends a<br /> {<br /> <br /> public $name="b";<br /> <br /> public function test2()<br /> {<br /> parent::test1();<br /> }<br /> }<br /> <br /> $a=new b();<br /> $a->test2();