如何在PHP中调用的函数中获取调用文件的绝对路径?

use*_*729 3 php path

file.php:

call()...
Run Code Online (Sandbox Code Playgroud)

如何获得file.php内部的绝对路径call()

注意call()可能在另一个文件中定义.

another.php:

function call(){..}
Run Code Online (Sandbox Code Playgroud)

file.php:

include(path_to_another.php);
call();
Run Code Online (Sandbox Code Playgroud)

use*_*291 10

没有办法除了debug_backtrace

function whatever() {
    $t = debug_backtrace();
    echo "called from {$t[0]['file']}";
}
Run Code Online (Sandbox Code Playgroud)