I'm looking for the equivalent of get_called_class() for __FILE__ ... Maybe something like get_included_file() ?
I have a set of classes that would like to know in which directory they exist. Something like that:
<?php class A { protected $baseDir; public function __construct() { $this->baseDir = dirname(__FILE__); } public function getBaseDir() { return $this->baseDir; } } ?>
And in another file, in another folder ...
<?php class B extends A {
Now I could do something ghetto, for example add $this->baseDir = dirname(__FILE__) to each expanding class, but that seems a bit ... ghetto. In the end, we are talking about PHP 5.3, right? Shouldn't it be the future?
Is there any other way to get the path to the file in which the class is declared?
source share