note 75894 deleted from language.constants.predefined by peehaa
| From: | peehaa@php.net | Date: | Mon, 22 May 2017 07:26:04 +0000 |
| Subject: | note 75894 deleted from language.constants.predefined by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-209085@lists.php.net to get a copy of this message | ||
Note Submitter: php at kennel17 dot co dot uk
----
Further to my previous note, the 'object' element of the array can be used to get the
parent object. So changing the get_class_static() function to the following will make the code
behave as expected:
<?php
function get_class_static() {
$bt = debug_backtrace();
if (isset($bt[1]['object']))
return get_class($bt[1]['object']);
else
return $bt[1]['class'];
}
?>
HOWEVER, it still fails when being called statically. Changing the last two lines of my previous
example to
<?php
foo::printClassName();
bar::printClassName();
?>
...still gives the same problematic result in PHP5, but in this case the 'object' property
is not set, so that technique is unavailable.