The debug_backtrace() function generates a backtrace.
This function displays data generated by the debug_backtrace() function code.
Returns an associative array. The following elements may be returned:
name | type | describe |
---|---|---|
function | string | The current function name. |
line | integer | The current line number. |
file | string | The current file name. |
class | string | The current class name. |
object | object | current object. |
type | string | Current call type, possible calls: Return: "->" - method call Returns: "::" - static method call Return nothing - function call |
args | array | If inside a function, list the function parameters. If in a referenced file, list the referenced file name. |
debug_backtrace()
<?phpfunction one($str1, $str2) { two("Glenn", "Quagmire"); }function two($str1, $str2) { three("Cleveland", "Brown"); }function three($ str1, $str2) { print_r(debug_backtrace()); }one("Peter", "Griffin");?>
The output of the above code looks like this:
Array([0] => Array ( [file] => C:webfoldertest.php [line] => 7 [function] => three [args] => Array ( [0] => Cleveland [1] => Brown ) )[1] => Array ( [file] => C:webfoldertest.php [line] => 3 [function] => two [args] => Array ( [0] => Glenn [1] => Quagmire ) )[2] => Array ( [file] => C:webfoldertest.php [line] => 14 [function] => one [args] => Array ( [0] => Peter [1] => Griffin ) ))