简体   繁体   中英

What is meant by backtrace in php why we use debug_backtrace() and debug_print_backtrace() functions in php?

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)

The debug_backtrace() is a function which generates a PHP backtrace(similar to python stack traceback).

This function displays data from the code that led up to the debug_backtrace() function and Returns an array of associative arrays

since you are new instead of http://php.net/manual/en/function.debug-backtrace.php you can visit https://www.w3schools.com/PhP/func_error_debug_backtrace.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM