note 85511 added to function.debug-backtrace
| From: | nyquist dot alexander at gmail dot com | Date: | Wed, 03 Sep 2008 08:00:54 +0000 |
| Subject: | note 85511 added to function.debug-backtrace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144105@lists.php.net to get a copy of this message | ||
Here's a short snippet on how to get the name of the calling class.
Example:
<?php
Class Foo
{
public static function say()
{
Bar::say();
}
}
Class Bar
{
public static function say()
{
echo "baz";
$trace = debug_backtrace();
$calling_class = $trace[count($trace)-1]["class"];
echo "Called from: " . $calling_class;
}
}
Foo::say();
?>
Will print "Called from Foo".
----
Server IP: 80.67.2.2
Probable Submitter: 85.195.5.212
----
Manual Page -- http://www.php.net/manual/en/function.debug-backtrace.php
Edit -- https://master.php.net/note/edit/85511
Del: integrated -- https://master.php.net/note/delete/85511/integrated
Del: useless -- https://master.php.net/note/delete/85511/useless
Del: bad code -- https://master.php.net/note/delete/85511/bad+code
Del: spam -- https://master.php.net/note/delete/85511/spam
Del: non-english -- https://master.php.net/note/delete/85511/non-english
Del: in docs -- https://master.php.net/note/delete/85511/in+docs
Del: other reasons-- https://master.php.net/note/delete/85511
Reject -- https://master.php.net/note/reject/85511
Search -- https://master.php.net/manage/user-notes.php