What does the PHP debug_backtrace () function do?

Source: Internet
Author: User
Definition and Usage

The PHP debug_backtrace () function generates a backtrace (backtracking information).

The function returns an associative array. The following are the elements that might be returned:

Name Type Describe
function String The current function name.
Line Integer The current line number.
File String The current file name.
Class String The current class name
Object Object The current object.
Type String The current invocation type, which may be called:
  • return: "--"-Method call

  • Return: "::"-static method call

  • Return Nothing-function call

Args Array If the function parameter is listed in the function. If in the referenced file, list the referenced file name.

Grammar

Debug_backtrace ()

Example

<?phpfunction One ($str 1, $str 2) {One ("Glenn", "quagmire");} function ($str 1, $str 2) {Three ("Cleveland", "Brown");} Function three ($str 1, $str 2) {Print_r (Debug_backtrace ());} One ("Peter", "Griffin");

Output:

Array (    [0] = = Array        (            [File] = D:\PHP\xampp\htdocs\52php\123\789.php [line] + =            7            [ Function] = three            [args]/= Array                (                    [0] = Cleveland                    [1] = Brown                )        )    [1] =& Gt Array        (            [File] = D:\PHP\xampp\htdocs\52php\123\789.php            [line] = 3            [function] =            [args] = Array                (                    [0] = Glenn                    [1] = Quagmire                )        )    [2] = = Array        (            [File] = D:\PHP\ xampp\htdocs\52php\123\789.php            [Line] = [            function] = one            [args] + Array                (                    [0 ] = Peter                    [1] = Griffin))        )

Debug_backtrace function Understanding 1

The Debug_backtrace function is to generate a backtrace.

The Debug_backtrace function returns an associative array.

1.backtrace how to understand;

2. Whether the associative array can be understood as being able to relate the new array to the original array;

Debug_backtrace Function Understanding 2

Parameters of the Debug_backtrace function

Functions: The current function name.

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

Line: The current row number.

Whether 1.line can be understood as the number of rows where the function is called;

File: the current filename.

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

Class: The current category name

Object: The current object.

Type: The current invocation type, possibly called:

return: "--"-Method call

Return: "::"-static method call

Return Nothing-function call

1. How the invocation of various methods is understood;

Args[] Array If the function parameter is listed in the function. If in the referenced file, list the referenced file name.

Debug_backtrace function Understanding 3

<?php function One ($str 1, $str 2) {One (  "Glenn", "quagmire"), and  function one ($str 1, $str 2) {  three (" Cleveland "," Brown ");  } Function three ($str 1, $str 2) {  Print_r (Debug_backtrace ());  }  One ("Peter", "Griffin");?>

Output:

Array ([0] = = Array ([file] = = C:\wamp\www\web.php [line] = [function] = three [args] = Array ([0] = Cleveland [1] = Brown)) [1] = = Array ([file] = C:\wamp\www\web.php [line] [] [function] = wo [args] = Array ([0] = Glenn [1] = quagmire)) [2] = = Array ([file] + C:\wamp\www\web.php [line] = > 94 [function] = one [args] = Array ([0] = Peter [1] = Griffin)))

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.