Debug_print_backtrace (), a php debugging tool (). If we want to know who called a method? Debug_print_backtrace can solve the problem that debug_print_backtrace () can print out a page call process. Where can this problem be solved? if we want to know who called 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
The 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
The 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.phpWhy? Debug_print_backtrace can solve the problem that debug_print_backtrace () can print a page call process, where to go and where to get a page...