Get child class namespace from superclass in PHP

后端 未结 6 1052
南旧
南旧 2020-12-09 02:24

Assuming I have the following classes in different files:



        
6条回答
  •  盖世英雄少女心
    2020-12-09 02:50

    As of PHP 5.3 you can use get_called_class and some string functions to achieve this.

    substr(get_called_class(), 0, strrpos(get_called_class(), "\\"))

提交回复
热议问题