class a1 extends class b{}
class a2 extends class b{}
class a3 extends class b{}
class a4 extends class b{}
class a5 extends class b{}
I need $this->filePath in each a1 to a5 that point to location of it’s file, but when I set $this->filePath = __FILE__ in parent, in children $this->filePath point to parent location
There is no way to do this globally in
b‘s constructor due to the nature of__FILE__– it does not behave like a function, but is a magic constant that gets processed (and replaced with its actual value) when the file is interpreted.You will have to do this in each child separately. This works in PHP 5:
The only way I know to do this in the parent is using
debug_backtrace(), and that is not a good practice.