Home > Backend Development > PHP Tutorial > php 调试利器debug_print_backtrace()_PHP

php 调试利器debug_print_backtrace()_PHP

WBOY
Release: 2016-06-01 12:11:03
Original
1290 people have browsed it

如果我们想知道某个方法被谁调用了? debug_print_backtrace可以解决
debug_print_backtrace() 可以打印出一个页面的调用过程 , 从哪儿来到哪儿去一目了然.
不过这是一个PHP5的专有函数,好在pear中已经有了实现,
http://pear.php.net/package/PHP_Compat

测试代码
复制代码 代码如下:
class a{
function say($msg) {
echo "msg:".$msg;
echo "

";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><u>复制代码</u> 代码如下: <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>http://ch2.php.net/manual/zh/function.debug-print-backtrace.php <br>http://ch2.php.net/manual/zh/function.debug-backtrace.php
    
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template