I want to replicate this:
$myObject = new object( __FILE__ );
class object {
protected $path_to_caller;
public function __construct( $file ){
$this->path_to_caller = dirname( $file );
}
}
Without having to pass the parameter, since it will be the same for every call. Is there a way to access the calling file/directory within a member function without using debug_backtrace()
?
Essentially, I want:
$myObject = new object();
class object {
protected $path_to_caller;
public function __construct(){
$this->path_to_caller = special_function(); // dirname( __FILE__ ) of caller
}
}