get filename of extended class

前端 未结 2 1741
心在旅途
心在旅途 2020-12-07 01:25

Let\'s say I have two files, each one has a class. How can I get the filename where the child class is, within the parent class?

File 2 (child class):



        
2条回答
  •  误落风尘
    2020-12-07 02:07

    Not really sure what purpose it serves, but here you go:

    class A{
    
      final protected function __construct(){
        $obj = new ReflectionClass($this);
        $filename = $obj->getFileName();
      }
    
    }
    

提交回复
热议问题