Accessing a parents variable from subclass php and parent keyword?

前端 未结 2 859
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 16:27

I have a parent class and a subclass, the parent class has a constructer that sets a var and I would like to use that var in the subclass, I have i

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-20 17:16

    Keyword parent should be used to access methods or static variables of parent class only, so your first code is the proper one, since $myVar is not static.

提交回复
热议问题