Produce a PHP backtrace:
<?php function a($txt) { b(“Glenn”); } function b($txt) { c(“Cleveland”); } function c($txt) { var_dump(debug_backtrace()); } a(“Peter”); ?> |
The debug_backtrace() function creates a PHP backtrace, showing data about the code execution leading up to the point where debug_backtrace() is called. It returns an array of associative arrays, with the following possible elements:
Name |
Type |
Description |
function |
string |
The name of the current function |
line |
integer |
The line number of the current execution |
file |
string |
The name of the current file |
class |
string |
The name of the current class |
object |
object |
The current instance |
type |
string |
The type of the current call. Possible values include:
|
args |
array |
If within a function, it lists the function’s arguments. If within an included file, it lists the names of the included files. |
debug_backtrace(options, limit); |
Parameter |
Description |
options |
Optional. Allows you to specify a bitmask for the following options:
|
limit |
Optional. Restricts the number of stack frames displayed. By default (when |
Return Value: |
An array of associative arrays |
PHP Version: |
4.3+ |
PHP Changelog: |
PHP 5.4: Introduced the optional limit parameter. PHP 5.3.6: Changed the provide_object parameter to options and added the DEBUG_BACKTRACE_IGNORE_ARGS option. PHP 5.2.5: Added the optional provide_object parameter. PHP 5.1.1: Included the current object as a possible return element. |