Getting the name of a child class in PHP

前端 未结 3 884
借酒劲吻你
借酒劲吻你 2020-12-22 02:12

Lets say I\'m building a base class which will be extended upon by the children class. So a base class is called Base and children can be Child1, <

3条回答
  •  悲哀的现实
    2020-12-22 03:07

    simply call get_class($this) - note however that a base class method has no real business in changing its behaviour depending on which derived class is using it. That's the whole point of deriving a class :)

提交回复
热议问题