Definition :
The debug_backtrace() is inbuilt function in php. The debug_backtrace() generates a PHP backtrace and returns this information as an associative array. The possible returned elements are listed in the following table:
Possible returned elements from debug_backtrace()
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. |
type | string | The current call type. If a method call, "->" is returned. If a static method call, "::" is returned. If a function call, nothing is returned. |
args | array | If inside a function, this lists the functions arguments. If inside an included file, this lists the included file name(s). |
debug_backtrace(options, limit);
Parameter | Description |
---|---|
options | Optional. Specifies a bitmask for the following options: DEBUG_BACKTRACE_PROVIDE_OBJECT (Whether or not to populate the "object" index 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 |
Let's understand with given below example of PHP debug_backtrace() :
Output :