PHP debug_print_backtrace() Function
The PHP debug_print_backtrace() function is used to print a PHP backtrace. This function displays data from the code that led up to the debug_print_backtrace() function.
Syntax
debug_print_backtrace(options, limit)
Parameters
options |
Optional. Specify this parameter as a bitmask for the following options:
|
limit |
Optional. This parameter can be used to limit the number of stack frames printed. By default (limit=0) it prints all stack frames. |
Return Value
No value is returned.
Example: debug_print_backtrace() example
The example below shows the usage of debug_print_backtrace() function.
<?php function test_a($x, $y){ echo "\$x + \$y = ".($x + $y)."\n"; debug_print_backtrace(); } test_a(10, 20); ?>
The output of the above code will be:
$x + $y = 30 #0 test_a(10, 20) called at [Main.php:7]
Example: debug_print_backtrace() example
Consider one more example on debug_print_backtrace() function.
<?php function test_a($str){ test_b($str); } function test_b($str){ test_c($str); } function test_c($str){ echo "Hi $str \n"; debug_print_backtrace(); } test_a('friend'); ?>
The output of the above code will be:
Hi friend #0 test_c(friend) called at [Main.php:7] #1 test_b(friend) called at [Main.php:3] #2 test_a(friend) called at [Main.php:15]
❮ PHP Error Handling Reference