Getting the name of a child class in the parent class (static context)

前端 未结 9 941
栀梦
栀梦 2020-11-29 20:19

I\'m building an ORM library with reuse and simplicity in mind; everything goes fine except that I got stuck by a stupid inheritance limitation. Please consider the code bel

9条回答
  •  无人及你
    2020-11-29 20:49

    I know its old post but want to share the solution I have found.

    Tested with PHP 7+ Use the function get_class()link

    
    

    The above example will output:

    string(3) "foo"
    string(3) "bar"
    

提交回复
热议问题