我想复制这个:
$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
}
}