我想复制这个:
$myObject = new object( __FILE__ );
class object {
protected $path_to_caller;
public function __construct( $file ){
$this->path_to_caller = dirname( $file );
}
}
无需传递参数,因为每次调用都是相同的。有没有办法在不使用debug_backtrace()
的情况下访问成员函数中的调用文件/目录?
基本上,我想:
$myObject = new object();
class object {
protected $path_to_caller;
public function __construct(){
$this->path_to_caller = special_function(); // dirname( __FILE__ ) of caller
}
}