note 75892 added to function.debug-backtrace
| From: | php at kennel17 dot co dot uk | Date: | Wed, 20 Jun 2007 16:30:08 +0000 |
| Subject: | note 75892 added to function.debug-backtrace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127832@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.197
Probable Submitter: 85.210.211.75
----
Manual Page -- http://www.php.net/manual/en/function.debug-backtrace.php
Edit -- https://master.php.net/note/edit/75892
Del: integrated -- https://master.php.net/note/delete/75892/integrated
Del: useless -- https://master.php.net/note/delete/75892/useless
Del: bad code -- https://master.php.net/note/delete/75892/bad+code
Del: spam -- https://master.php.net/note/delete/75892/spam
Del: non-english -- https://master.php.net/note/delete/75892/non-english
Del: in docs -- https://master.php.net/note/delete/75892/in+docs
Del: other reasons-- https://master.php.net/note/delete/75892
Reject -- https://master.php.net/note/reject/75892
Search -- https://master.php.net/manage/user-notes.php