I am new to php and learning it from php.net and currently I am reading about debugging using debug_backtrace().
Can anyone tell me what is meant by backtrace and why we use debug_backtrace() and debug_print_backtrace() functions in php ?
PHP backtrace family of functions let you understand how the functions have been called in the particular request.
For example if you have called function foo()
before function bar()
, then if you write debug print backtrace in bar()
function then you will see foo()
has been called before bar()
function. This also provides you what arguments you have passed to bar()
function.
This helps you to trace back where and what functions are called to reach the current line of code (where you have written the backtrace function)