Debug_print_backtrace () is a very low-key function, which is rarely noticed. however, when an error occurs when I call another object to call another object and a function in another object or file, it is smiling. if we want to know who calls a method? Debug_print_backtrace
Debug_print_backtrace () can print out the call process of a page, from where to see clearly.
However, this is a PHP5 proprietary function. Fortunately, it has been implemented in pear,
Http://pear.php.net/package/PHP_Compat
Test Code
Copy codeThe code is as follows:
Class {
Function say ($ msg ){
Echo "msg:". $ msg;
Echo"
"; Debug_print_backtrace ();
}
}
Class B {
Function say ($ msg ){
$ A = new ();
$ A-> say ($ msg );
}
}
Class c {
Function _ construct ($ msg ){
$ B = new B ();
$ B-> say ($ msg );
}
}
$ C = new c ("test ");
Output result
Copy codeThe code is as follows:
Msg: test
#0 a-> say (test) called at [/var/www/test/test0723.php: 12]
#1 B-> say (test) called at [/var/www/test/test0723.php: 19]
#2 c->__ construct (test) called at [/var/www/test/test0723.php: 23]
Related links
Http://ch2.php.net/manual/zh/function.debug-print-backtrace.php
Http://ch2.php.net/manual/zh/function.debug-backtrace.php