Get class name from extended class

后端 未结 3 743
旧时难觅i
旧时难觅i 2021-01-04 04:20

Is it possible to get the name of the top level class from an extended class, without setting it from the top level class. See example below, I would like to get \'Foo\' fro

相关标签:
3条回答
  • 2021-01-04 04:37

    get_called_class() for static classes or get_class($this) for instantiated.

    get_called_class(), as Jason said, was introduced in PHP 5.3

    0 讨论(0)
  • 2021-01-04 04:38

    Use:

    get_class($this);
    
    0 讨论(0)
  • 2021-01-04 04:56

    You can simply use:

    get_class($this);
    
    0 讨论(0)
提交回复
热议问题