获取函数调用位置的文件名


Getting the filename of where a function was called from

是否可以(在高效的庄园中)检索调用另一个(包含的)文件中函数的上一个命令的文件名(如果可能的话,还有行)?

例如:

Foo.php

function foo() {
    bar();
}

Bar.php

function bar() {
    // some stuff that will show when the above is executed:
    // Foo.php, line 2 (last bit if possible)
}

这是debug_backtrace():的工作

function test($param)
{
    echo "$param";
    var_dump(debug_backtrace());
}