PHP debug_backtrace() Function

The debug_backtrace() function generates a PHP backtrace.This function displays data from the code that led up to the debug_backtrace() function.

Example -

The above code will output something like this:

Returns an array of associative arrays. The possible returned elements are:

NameTypeDescription
functionstringThe current function name
lineintegerThe current line number
filestringThe current file name
classstringThe current class name
objectobjectThe current object
typestringThe current call type. Possible calls:
  • Returns: "->" - Method call
  • Returns: "::" - Static method call
  • Returns nothing - Function call
  • argsarrayIf inside a function, it lists the functions arguments. If inside an included file, it lists the included file names

    ParameterDescription
    optionsOptional. 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)
    limitOptional. Limits the number of stack frames printed. By default (limit=0) it prints all stack frames