Home  >  Article  >  Backend Development  >  Usage of the php debugging tool debug_print_backtrace() function

Usage of the php debugging tool debug_print_backtrace() function

怪我咯
怪我咯Original
2017-07-10 14:19:511240browse

debug_print_backtrace() is a very low-key function, few people pay attention to it. But when I call another object on an object and then call other objects and a function in the file and an error occurs, it is laughing.

If we Want to know who called a certain method? debug_print_backtrace can solve it
debug_print_backtrace() can print out the calling process of a page, and it is clear where it comes from.
But this is a proprietary function of PHP5, okay There is already an implementation in pear,
http://pear.php.net/package/PHP_Compat

Test code, The code is as follows:

<?php 
class a{ 
function say($msg) { 
echo "msg:".$msg; 
echo "<pre class="brush:php;toolbar:false">";debug_print_backtrace(); 
} 
} 

class b { 
function say($msg) { 
$a = new a(); 
$a->say($msg); 
} 
} 

class c { 
function construct($msg) { 
$b = new b(); 
$b->say($msg); 
} 
} 

$c = new c("test");

Output The result

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]

The above is the detailed content of Usage of the php debugging tool debug_print_backtrace() function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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