In this article, you will learn how to print PHP backtrace. The debug_print_backtrace() function in PHP prints a PHP backtrace.
This function displays data from the code that led up to the debug_print_backtrace() function.
what is the syntax of the DEBUG_PRINT_BACKTRACE() function in php?
debug_print_backtrace(options, limit);
Parameter | Description |
---|---|
options | Optional. Specifies a bitmask for the following option: DEBUG_BACKTRACE_IGNORE_ARGS (Whether or not to omit the “args” index, and all the function/method arguments, to save memory) |
limit | Optional. Limits the number of stack frames printed. By default (limit=0) it prints all stack frames |
examples of the DEBUG_PRINT_BACKTRACE() function
Example 1. In this example, we print a PHP backtrace.
<?php
function a($txt) {
b("Glenn");
}
function b($txt) {
c("Cleveland");
}
function c($txt) {
debug_print_backtrace();
}
a("Peter");
?>