PHP Debug Backtrace:
Debug Backtrace or debug_backtrace() is used to generate the backtrace in PHP in associative array format. General format of the function is:
array debug_backtrace (<bool $provide_object = true >)
Probable list of returned elements from debug_backtrace() are as below:
| Name | Type | Description |
|---|---|---|
| Function | String | Current function name |
| Line | Integer | Current line number |
| File | String | Current file name |
| Class | String | Current file name |
| Object | String | Current object name |
| Type | String | Current call type, e.g. returns -> for method call, returns :: for static method call, and returns nothing function call |
| Args | Array | If inside a function then list of the arguments |
Example:
<?php
function
one($var1,$var2){two(
"Hello","World");}
function
two($var1,$var2){print_r(debug_backtrace());
echo"<br/>";}
one(
"rose","india");?>
Output:
Array ( [0] => Array ( [file] =>../error.php [line] => 3 [function] => two [args] => Array ( [0] => Hello [1] => World ) ) [1] => Array ( [file] => ../error.php [line] => 10 [function] => one [args] => Array ( [0] => rose [1] => india ) ) )