How to get the path of a derived class from an inherited method?

前端 未结 6 1821
轮回少年
轮回少年 2021-01-30 13:11

How to get the path of the current class, from an inherited method?

I have the following:



        
6条回答
  •  一整个雨季
    2021-01-30 13:28

    Yes. Building on Palantir's answer:

       class Parent  {
          protected function getDir() {
             $rc = new ReflectionClass(get_class($this));
             return dirname($rc->getFileName());
          }
       }
    

提交回复
热议问题