假设我有两个文件,每个文件都有一个类.如何在父类中获取子类所在的文件名?
文件2(子类):
class B extends A{
}
Run Code Online (Sandbox Code Playgroud)
档案1:
class A{
final protected function __construct(){
// here I want to get the filename where class B is,
// or whatever class is the child
}
}
Run Code Online (Sandbox Code Playgroud)
Tim*_*per 16
不确定它的用途是什么,但是你走了:
class A{
final protected function __construct(){
$obj = new ReflectionClass($this);
$filename = $obj->getFileName();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2770 次 |
| 最近记录: |