PHP debug_print_backtrace() 函數

Example

打印一條 PHP 回溯:

<?php
 function a($txt) {
     b("Glenn");
 }
 function b($txt) {
     c("Cleveland");
}
 function c($txt) {
     debug_print_backtrace();
 }
 a("Peter");
 ?> 

以上代碼的輸出類似這樣:

#0 c(Cleveland) called at [C:\webfolder\test.php:6]
 #1 b(Glenn) called at [C:\webfolder\test.php:3]
 #2 a(Peter) called at [C:\webfolder\test.php:11]

定義和用法

debug_print_backtrace() 函數打印 PHP 回溯(backtrace)。

debug_print_backtrace() 打印了一條 PHP 回溯。它打印了函數調用、被 included/required 的文件和 eval() 的代碼。

語法

debug_print_backtrace(options,limit);
參數 描述
options

可選。規定以下參數的位掩碼:

  • DEBUG_BACKTRACE_IGNORE_ARGS(是否忽略 "args" 的索引,包括所有的 function/method 的參數,能夠節省內存開銷。)
limit 可選。用于限制返回堆棧幀的數量。默認為 (limit=0) ,返回所有的堆棧幀。

技術細節

返回值: None
PHP 版本: 5.0+
PHP 更新日志:

PHP 5.4:添加了可選的參數 limit

PHP 5.3.6: 添加了可選的參數 options