Home > php教程 > PHP开发 > body text

How to learn PHP debug_backtrace()

黄舟
Release: 2016-12-28 13:35:23
Original
1578 people have browsed it

Debug_backtrace function understanding 1

The function of debug_backtrace function is to generate a backtrace.

The debug_backtrace function returns an associative array.

1. How to understand backtrace;

2. Can associative arrays be understood as a new array that is related to the original array;



debug_backtrace function understanding 2

Parameters of debug_backtrace function


function: the current function name.

1. Whether the current function name is a custom function or a system function;

line: the current line number.

1. Can line be understood as the number of lines where the function is called?

file: the current file name.

1.file can be understood as the file where the current debugging is located

class: the current class name

object: the current object.

type: current call type, possible calls:

Return: "->" - method call

Return: "::" - static method call

Return nothing - function call

1. How to understand the calls of various methods;


If the args[] array is in the function, List function parameters. If in a referenced file, list the referenced file name.




##debug_backtrace function understanding 3

<?php 
function one($str1, $str2) { 
 two("Glenn", "Quagmire"); 
 } 
function two($str1, $str2) { 
 three("Cleveland", "Brown"); 
 } 
function three($str1, $str2) { 
 print_r(debug_backtrace()); 
 } 
 one("Peter", "Griffin");
Copy after login

?>

Output:

Array ( [0] => Array ( [file] => C:\wamp\www\web.php [line] => 89 [function] => three [args] => Array ( [0] => Cleveland [1] => Brown ) ) 
[1] => Array ( [file] => C:\wamp\www\web.php [line] => 86 [function] => two [args] => Array ( [0] => Glenn [1] => Quagmire ) ) 
[2] => Array ( [file] => C:\wamp\www\web.php [line] => 94 [function] => one [args] => Array ( [0] => Peter [1] => Griffin ) ) )
Copy after login

The above is how to learn PHP debug_backtrace(). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!



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