I have a base class called Parent
. Within parent I am setting a class property, $this->admin = TRUE
;
I also have a child class we'll call Child
. The constructor for Child
calls the parent constructor. I was under the impression that when you set a class property int he parent class, that property is inherited by the child, unless you override it. yet when I test to see if $this->admin
is set I get false. Did I get the concept of inheritance wrong?
不能使用$ this-> prop来访问类属性 ,而只能使用self :: $ prop来访问该属性,还应确保该属性未设置为private
而是设置为public
或protected
以便将其继承给子类。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.