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