Debugging information about the Debug_backtrace () function in PHP at the print call

Source: Internet
Author: User
This article mainly introduces about PHP in the Debug_backtrace () function printing call at the debugging information, has a certain reference value, now share to everyone, the need for friends can refer to

Debug_backtrace

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

debug_backtrace- generates a backtracking trace (backtrace)

Description

Array debug_backtrace ([ int $options = debug_backtrace_provide_object [, int $limit = 0]])

Debug_backtrace () generates a trace of PHP (BackTrace).

Parameters

    • options

    • As of 5.3.6, this parameter is a bitmask of the following options:

      Debug_backtrace () option
      Debug_backtrace_provide_object Whether to populate the index of "object".
      Debug_backtrace_ignore_args Whether to ignore the "args" index, including all Function/method parameters, can save memory overhead.

      Before 5.3.6, only the values that can be used are TRUE or are FALSE equal to whether the option is set DEBUG_BACKTRACE_PROVIDE_OBJECT .

    • limit

    • As of 5.4.0, this parameter can be used to limit the number of return stack frames. The default is ( limit =0), which returns all stack frames.

return value

Returns an array containing a number of associative arrays . Elements that are expected to be returned:

It is possible to return elements from Debug_backtrace ()
name type Description
function String The current function name, see: __function__.
Line Integer The current line number. See also: __line__.
File String The current file name. See also: __file__.
Class String The name of the current class. See __class__
Object Object The current object.
Type String The type of the current call. If it is a method, it returns "--". If it is a static method, it returns "::". If it is a function call, it returns NULL.
Args Array If in a function, this lists the parameters of the function. If it is in a contained file, the included file name is listed.

Update log

version Description
5.4.0 Optional parameters have been added limit .
5.3.6 Parameters are changed and optional provide_object options parameters are added DEBUG_BACKTRACE_IGNORE_ARGS .
5.2.5 Optional parameters have been added provide_object .
5.1.1 Added the current object as an element that may be returned.

Example

Example #1 debug_backtrace () example

<?php//filename:/tmp/a.phpfunction a_test ($str) {    echo "\nhi: $str";    Var_dump (Debug_backtrace ());} A_test (' friend ');? ><?php//filename:/tmp/b.phpinclude_once '/tmp/a.php ';? >

The execution returns a result similar to the following:

Hi:friendarray (2) {[0]=>array (4) {    ["file"] and "/tmp/a.php" ["line    "] = Int (ten)    [" function "] = = string (6)" A_test "    [" args "]=>    Array (1) {      [0] = &string (6)" Friend "    }}[1]= >array (4) {    ["file"] + = string (Ten) "/tmp/b.php"    ["line"] = + int (2)    ["args"] = =    Array (1 {      [0] = = string (Ten) "/tmp/a.php"    }    ["function"] = = string (+) "Include_once"}  }

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

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.