debug_print_backtrace() 是一个很低调的函数,很少有人注意过它.不过当我对着一个对象调用另一个对象再调用其它的对象和文件中的一个函数出错时,它正在一边笑呢
如果我们想知道某个方法被谁调用了? debug_print_backtrace可以解决
";debug_print_backtrace(); <br>} <br>} <br><br>class b { <br>function say($msg) { <br>$a = new a(); <br>$a->say($msg); <br>} <br>} <br><br>class c { <br>function __construct($msg) { <br>$b = new b(); <br>$b->say($msg); <br>} <br>} <br><br>$c = new c("test"); <br> <br>输出结果 <br><span style="CURSOR: pointer" onclick="doCopy('code6618')"><u>复制代码</u></span> 代码如下: <br>msg:test <br>#0 a->say(test) called at [/var/www/test/test0723.php:12] <br>#1 b->say(test) called at [/var/www/test/test0723.php:19] <br>#2 c->__construct(test) called at [/var/www/test/test0723.php:23] <br> <br>相关链接 <br><br> <br>