解决方案可能是使用
debug_backtrace功能:在回溯中,应该存在那种信息。
或者,正如Gordon在评论中指出的那样,如果只想输出该信息并且不能使用,也可以使用debug_print_backtrace。
例如,使用包含以下内容的temp.php:
include 'temp-2.php';
my_function();
和temp-2.php包含这个:
function my_function() {
var_dump(debug_backtrace());
}
从我的浏览器调用temp.php(即第一个脚本)得到我的输出:
array
0 =>
array
'file' => string '/.../temp/temp.php' (length=46)
'line' => int 5
'function' => string 'my_function' (length=11)
'args' =>
array
empty
在那里,我有“temp.php”文件名 – 这是函数被调用的文件。
当然,你必须测试一下(特别是在这个功能不在“第一级”包含的文件的情况下,但在另一个文件中包含的文件中 – 不能确定debug_backtrace会有很大的帮助。 。);但这可能有助于您获得第一个想法…