MENU
Backtrace
debug_backtrace([$i1[,$i2=0]]) returns an associative array containing the backtrace. $i1 can be DEBUG_BACKTRACE_PROVIDE_OBJECT or DEBUG_BACKTRACE_IGNORE_ARGS. $i2 limits the number of stack frames returned. By default ($i2=0) it returns all stack frames. debug_print_backtrace ([$i1[,$i2]]) prints the backtrace. $i1 can be DEBUG_BACKTRACE_IGNORE_ARGS. $i2 limits the number of stack frames used. By default ($i2=0) it prints all stack frames.test.php:
<?php // test.php
function a() {b();}
function b() {
print_r(debug_backtrace());
echo "<br /><br />";
debug_print_backtrace();
}
a();
?><!DOCTYPE html><html><head></head>
<body><?php
include "test.php";
?> </body></html>Array ( [0] => Array ( [file] => E:\Program Files\xampp\htdocs\test.php
[line] => 3
[function] => b
[args] => Array ( ) )
[1] => Array ( [file] => E:\Program Files\
xampp\htdocs\test.php
[line] => 10
[function] => a
[args] => Array ( ) )
[2] => Array ( [file] => E:\Program Files\
xampp\htdocs\intro.php
[line] => 4
[args] => Array ( [0] => E:\Program Files\
xampp\htdocs\test.php )
[function] => include ) )
#0 b() called at [E:\Program Files\xampp\htdocs\test.php:3]
#1 a() called at [E:\Program Files\xampp\htdocs\test.php:10]
#2 include(E:\Program Files\xampp\htdocs\test.php) called at [E:\Program Files\xampp\htdocs\intro.php:4]RESETRUNFULL
<?php // last-test.php
function a() {b();}
function b() {
print_r(debug_backtrace());
echo "<br /><br />";
debug_print_backtrace();
}
a();
?><!DOCTYPE html><html><head></head>
<body><?php
echo $a;
print_r(error_get_last());
?> </body></html>