如何在PHP调用的函数中获取调用文件的绝对路径? [英] How to get the absolute path of the calling file in a function that's called in PHP?
本文介绍了如何在PHP调用的函数中获取调用文件的绝对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在file.php
中:
call()...
如何在call()
内部获取file.php
的绝对路径?
How to get absolute path of file.php
inside call()
?
请注意call()
可能在另一个文件中定义.
Pay attention that call()
may be defined in another file.
another.php
:
function call(){..}
file.php
:
include(path_to_another.php);
call();
推荐答案
function whatever() {
$t = debug_backtrace();
echo "called from {$t[0]['file']}";
}
这篇关于如何在PHP调用的函数中获取调用文件的绝对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文