Posted by Jason Barnett on 10/04/86 11:05
>
> __CLASS__ contains the name of the class the method is in. In my sample it
> would be 'Car' and not 'Porsche'.
>
> What I don't understand is why the behaviour of debug_backtrace() has been
> changed!?!
>
> Regards, Torsten
I have no idea why the behaviour changed (I didn't really use the
function before, either). And I see now the change in the manual that
addresses this (essentially debug_backtrace gives you __CLASS__)
If you had an actual instance of the class you could use get_class, but
alas you are using a static method call. You punk.
The only other solution that comes to mind is a little messy but it lets
you get away with no object. Instead of calling the method statically
you can use call_user_func_array() with the child class name as a
parameter. Then change the parent method to accept the child class name
as a parameter.
<?php
function call_static_child() {
$drive_args = func_get_args();
/** assume that first parameter is child of class Car */
return call_user_func_array(array($drive_args[0], 'drive'), $drive_args);
}
?>
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2
[Back to original message]
|