Definition and usage
The PHP debug_backtrace () function generates a backtrace.
This function returns an associated array. The following elements may be returned:
| Name |
Type |
Description |
| Function |
String |
The current function name. |
| Line |
Integer |
The current row number. |
| File |
String |
The current file name. |
| Class |
String |
Current Class Name |
| Object |
Object |
Current object. |
| Type |
String |
The current call type. Possible calls:
- Return Value: "->"-method call
- Return Value: ":"-static method call
- Return nothing-function call
|
| ARGs |
Array |
If function parameters are listed. If the referenced file lists the referenced file names. |
Syntax
debug_backtrace()
Example
<?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");?>
Output:
Array([0] => Array ( => C:/webfolder/test.php [line] => 7 [function] => three [args] => Array ( [0] => Cleveland [1] => Brown ) )[1] => Array ( => C:/webfolder/test.php [line] => 3 [function] => two [args] => Array ( [0] => Glenn [1] => Quagmire ) ) [2] => Array ( => C:/webfolder/test.php [line] => 14 [function] => one [args] => Array ( [0] => Peter [1] => Griffin ) ))