Home > Article > Backend Development > Introduction to php bug debugging assistant debug_print_backtrace()
This article mainly introduces the introduction of the PHP bug debugging assistant debug_print_backtrace(), which has a certain reference value. Now I share it with you. Friends in need can refer to it
debug_print_backtrace() is a very A low-key function, few people have paid attention to it. But when I call another object on one object and then call other objects and a function in the file and make an error, it may be 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,
Case 1
<?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");
Case 2
<?php function one($str1, $str2) { two("Glenn", "Quagmire"); } function two($str1, $str2) { three("Cleveland", "Brown"); } function three($str1, $str2) { echo '<pre class="brush:php;toolbar:false">'; debug_backtrace(); } echo one('a','b');?>
The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
php http_build_query stream_context_create post request
The above is the detailed content of Introduction to php bug debugging assistant debug_print_backtrace(). For more information, please follow other related articles on the PHP Chinese website!