PHP Debug_backtrace () function

Source: Internet
Author: User

PHP Error and Logging functions

Instance

Generate PHP BackTrace:

<?php function A ($txt) {     B ("Glenn"),} function B ($txt) {     C ("Cleveland"),} function C ($txt) {     var_dump (debug_backtrace()

The output of the above code is similar to this:

Array (     [0] = = Array (         [file] = C:\webfolder\test.php         [line] = 6         [function] + C         [args] ] = = Array (             [0] = Cleveland         )     )     [1] = = Array (         [file] = C:\webfolder\test.php         [ Line] = 3         [function] = b         [args] = array (             [0] = Glenn         )     )     [2] = = Array ( C17/>[file] = C:\webfolder\test.php         [line] = [         function] = a         [args] + Array (             [0] (Peter         )))     
Definition and usage

The Debug_backtrace () function generates a backtrace (backtracking trace).

The function displays the data generated by the Debug_backtrace () function code.

Returns an associative array. The elements that might be returned are as follows:

name type Description
function String Current function name
Line Integer Current line number
File String Current file name
Class String Current class name
Object Object Current Object
Type String

The current invocation type. Possible calls:

  • 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 (options,limit);
Parameters Description
Options

Optional. Bitmask that specifies the following options:

  • Debug_backtrace_provide_object (whether to populate the index of "OBJECT")
  • Debug_backtrace_ignore_args (whether to ignore the "ARGS" index, including all the Function/method parameters, can save memory overhead.) )
Limit Optional. Limits the number of stack frames returned. The default is (limit=0), which returns all stack frames.
Technical details
return value: None
PHP version: 4.3+
PHP Update Log

PHP 5.4: Added optional parameter limit.

PHP 5.3.6: Parameter provide_object is changed to options, and optional parameter Debug_backtrace_ignore_args is added.

PHP 5.2.5: Optional parameter provide_objectis added.

PHP 5.1.1: Added the current object as an element that may be returned.

PHP Error and Logging functions

PHP Debug_backtrace () function

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.