Home > php教程 > PHP开发 > PHP debugging tool debug_print_backtrace()

PHP debugging tool debug_print_backtrace()

黄舟
Release: 2016-12-28 13:40:14
Original
1309 people have browsed it

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 PHP5 Proprietary function, fortunately it has been implemented in pear,
http://pear.php.net/package/PHP_Compat

Test code

<?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");
Copy after login

Output result

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]
Copy after login

The above is the content of the PHP debugging tool debug_print_backtrace(). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template