In this article, you will learn how to generate a PHP backtrace. The debug_backtrace() function in PHP outputs a PHP backtrace. This function displays data from the code that led up to the debug_backtrace() function.
what is the syntax of the DEBUG_BACKTRACE() function in php?
Possible return values of the PHP debug_backtrace() function are:
Name | Type | Description |
---|---|---|
function | string | The current function name |
line | integer | The current line number |
file | string | The current file name |
class | string | The current class name |
object | object | The current object |
type | string | The current call type. Possible calls:Returns: “->” – Method callReturns: “::” – Static method callReturns nothing – Function call |
args | array | If inside a function, it lists the functions arguments. If inside an included file, it lists the included file names |
examples of the DEBUG_BACKTRACE() function
Example 1. In this example, we generate a PHP backtrace.
<?php
function a($txt) {
b("Glenn");
}
function b($txt) {
c("Cleveland");
}
function c($txt) {
var_dump(debug_backtrace());
}
a("Peter");
?>