PHP のアクセス制御の問題について
<br />class MyClass{<br /> public $public = 'public';<br /> protected $protected = 'protected';<br /> private $private = 'private';<br /> <br /> function printHello(){<br /> echo $this->public;<br /> echo $this->protected;<br /> echo $this->private . "<br/>";<br /> }<br />}<br /><br />$obj = new MyClass();<br />$obj->printHello();<br /><br />class MyClass2 extends MyClass{<br /> <br /> function printHello(){<br /> echo $this->public;<br /> echo $this->protected;<br /> echo $this->private . "<br/>";<br /> }<br />}<br /><br />$obj2 = new MyClass2();<br />$obj2->printHello(); // 输出 Public、Protected 和 Undefined<br />class MyClass3 extends MyClass{<br /> <br />}<br /><br />$obj3 = new MyClass3();<br />$obj3->printHello(); // 输出 Public、Protected 和 private<br />