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

前端 未结 6 1820
轮回少年
轮回少年 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:40

    You can also pass the directory as constructor arg. Not super elegant, but at least you don't have to work with reflection or composer.

    Parent:

    directory = $directory;
          }
    
          protected function getDir() {
             return $this->directory;
          }
       }
    ?>
    

    Child:

    getDir(); 
          }
       }
    ?>
    

提交回复
热议问题