PHP debug_backtrace() function
Halimbawa
Gumawa ng PHP backtrace:
<?php function a($txt) { b("Glenn"); } function b($txt) { c("Cleveland"); } function c($txt) { var_dump(debug_backtrace()); } a("Peter"); ?>
Ang output ng code na ito ay kahalintulad nang ito:
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 ( [file] => C:\webfolder\test.php [line] => 11 [function] => a [args] => Array ( [0] => Peter ) ) )
Paggalaw at paglalarawan
Ang function na debug_backtrace() ay gumagawa ng backtrace (backtracking).
Ang function na ito ay nagpapakita ng datos na ginawa ng code ng function na debug_backtrace().
Makabintang ang isang korelatibong array. Ang posibleng mga elemento na maibabalik ay tulad nang ito:
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 |
Current call type. Possible calls:
|
args | array | If in a function, list function parameters. If in a referenced file, list the referenced file name. |
Syntax
debug_backtrace(options,limit);
Parameter | Description |
---|---|
options |
Optional. Specify the bitmask for the following options:
|
limit | Optional. Limit the number of stack frames returned. The default is (limit=0) Returns all stack frames. |
Technical Details
Return Value: | None |
---|---|
PHP Version: | 4.3+ |
PHP Update Log |
PHP 5.4: Added optional parameters limit. PHP 5.3.6: Parameter provide_object Changed to optionsand added optional parameter DEBUG_BACKTRACE_IGNORE_ARGS. PHP 5.2.5: Added optional parameters provide_object. PHP 5.1.1: Added the current object For elements that may be returned. |