note 75890 deleted from function.debug-backtrace by cmb
| From: | cmb@php.net | Date: | Sun, 17 Nov 2019 08:31:16 +0000 |
| Subject: | note 75890 deleted from function.debug-backtrace by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213065@lists.php.net to get a copy of this message | ||
Note Submitter: php at kennel17 dot co dot uk
----
The value of the class argument has changed slightly between PHP4 and PHP5:
Here's an example:
<?php
function get_class_static() {
$bt = debug_backtrace();
$name = $bt[1]['class'];
return $name;
}
class foo {
function printClassName() {
print(get_class_static() . "\n");
}
}
class bar extends foo {
}
$f = new foo();
$b = new bar();
$f->printClassName();
$b->printClassName();
?>
In PHP4 you get:
foo
bar
In PHP5 you get:
foo
foo
debug_backtrace() now sets the 'class' parameter to be the class that the function is
actually defined in, not the name of the instantiated class.