我已经查过了,我知道答案可能涉及使用debug_backtrace()
,但我正在努力研究如何使用它或它究竟做了什么。
基本上,如果这是 index.php:
<?php
//some code
//some more code
require "functions.php";
print_line();
//some code
print_line();
?>
和functions.php是:
<?php
function print_line(){
$line="[line that this function was called at]";
print "This function was called from line $line of index.php<br />";
}
?>
正确的设置方法是什么,$line
以便输出为:
This function was called from line 7 of index.php
This function was called from line 11 of index.php