debug_backtrace in PHP

Syntax of debug_backtrace

array debug_backtrace([ int options [, int limit ]])

Returns an array of associative arrays containing a backtrace of where PHP is currently executing. One element is included per function or file include, with the following elements

function If in a function, the function’s name as a string
line The line number within the file where the current function or file include is located
file The name of the file the element is in
class If in an object instance or class method, the name of the class the element is in
object If in an object, that object’s name
type The current call type: :: if a static method; -> if a method; nothing if a function
args If in a function, the arguments used to call that function; if in a file include, the include file’s name

Each function call or file include generates a new element in the array. The innermost function call or file include is the element with an index of zero; further elements are less deep function calls or file includes.

Leave a Comment