Debug_backtrace function understanding 1
The function of debug_backtrace function is to generate a backtrace.
The debug_backtrace function returns an associative array.
1. How to understand backtrace;
2. Can associative arrays be understood as a new array that is related to the original array;
debug_backtrace function understanding 2
Parameters of debug_backtrace function
function: the current function name.
1. Whether the current function name is a custom function or a system function;
line: the current line number.
1. Can line be understood as the number of lines where the function is called?
file: the current file name.
1.file can be understood as the file where the current debugging is located
class: the current class name
object: the current object.
type: current call type, possible calls:
Return: "->" - method call
Return: "::" - static method call
Return nothing - function call
1. How to understand the calls of various methods;
If the args[] array is in the function, List function parameters. If in a referenced file, list the referenced file name.
<?php function one($str1, $str2) { two("Glenn", "Quagmire"); } function two($str1, $str2) { three("Cleveland", "Brown"); } function three($str1, $str2) { print_r(debug_backtrace()); } one("Peter", "Griffin");?>
Output:
Array ( [0] => Array ( [file] => C:\wamp\www\web.php [line] => 89 [function] => three [args] => Array ( [0] => Cleveland [1] => Brown ) ) [1] => Array ( [file] => C:\wamp\www\web.php [line] => 86 [function] => two [args] => Array ( [0] => Glenn [1] => Quagmire ) ) [2] => Array ( [file] => C:\wamp\www\web.php [line] => 94 [function] => one [args] => Array ( [0] => Peter [1] => Griffin ) ) )The above is how to learn PHP debug_backtrace(). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!