Calling Static Method from Class B(which extends Class A) of Class A

后端 未结 5 1660
遇见更好的自我
遇见更好的自我 2021-01-03 04:02

There was an interesting question in a practice test that I did not understand the answer to. What is the output of the following code:



        
5条回答
  •  盖世英雄少女心
    2021-01-03 04:14

    If you call the static method bound to the other object, the method is executed in the context of the current object. Which allows access to the $this-object.

    Better way to call the superclass-method from inside the subclass would be:

    parent::getName();
    

提交回复
热议问题