Get name of extending class with static method call (PHP5)
| From: | Torsten Roehr | Date: | Wed, 12 Jan 2005 15:58:20 +0000 |
| Subject: | Get name of extending class with static method call (PHP5) | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-14357@lists.php.net to get a copy of this message | ||
Hi devs,
after a long discussion on php-general [1], searching the archives and
trying every proposed solution without success I'm asking for your help to
solve the following problem:
class Car {
function drive() {
// I need the name of the calling class here
// in my case it should be 'Porsche'
}
}
class Porsche extends Car {
}
Porsche::drive();
With PHP4 it was possible to get the correct class name with
debug_backtrace(). This behaviour has been changed in PHP5.
How can I get the name of the extending class that invoked the method in
drive()?
Thanks in advance!
Best regards, Torsten Roehr
[1] http://marc.theaimsgroup.com/?t=110546013200009&r=1&w=2
(following the
thread with a news client might be easier)