Home  >  Article  >  Backend Development  >  Introduction to php bug debugging assistant debug_print_backtrace()

Introduction to php bug debugging assistant debug_print_backtrace()

不言
不言Original
2018-07-04 15:07:311855browse

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 &#39;<pre class="brush:php;toolbar:false">&#39;;
    debug_backtrace();
}
echo one(&#39;a&#39;,&#39;b&#39;);?>

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!

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