note 110648 added to function.debug-backtrace
| From: | PhilHilton | Date: | Fri, 16 Nov 2012 18:57:36 +0000 |
| Subject: | note 110648 added to function.debug-backtrace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192014@lists.php.net to get a copy of this message | ||
Super simple example to output where your function was called from (file, function, line number):
# Prints the file name, function name, and
# line number which called your function
# (not this function, then one that called
# it to begin with)
function debugPrintCallingFunction () {
$file = 'n/a';
$func = 'n/a';
$line = 'n/a';
$debugTrace = debug_backtrace();
if (isset($debugTrace[1])) {
$file = $debugTrace[1]['file'] ? $debugTrace[1]['file'] : 'n/a';
$line = $debugTrace[1]['line'] ? $debugTrace[1]['line'] : 'n/a';
}
if (isset($debugTrace[2])) $func = $debugTrace[2]['function'] ?
$debugTrace[2]['function'] : 'n/a';
echo "<pre>\n$file, $func, $line\n</pre>";
}
----
Server IP: 69.147.83.199
Probable Submitter: 130.111.81.22
----
Manual Page -- http://www.php.net/manual/en/function.debug-backtrace.php
Edit -- https://master.php.net/note/edit/110648
Del: integrated -- https://master.php.net/note/delete/110648/integrated
Del: useless -- https://master.php.net/note/delete/110648/useless
Del: bad code -- https://master.php.net/note/delete/110648/bad+code
Del: spam -- https://master.php.net/note/delete/110648/spam
Del: non-english -- https://master.php.net/note/delete/110648/non-english
Del: in docs -- https://master.php.net/note/delete/110648/in+docs
Del: other reasons-- https://master.php.net/note/delete/110648
Reject -- https://master.php.net/note/reject/110648
Search -- https://master.php.net/manage/user-notes.php