如何在PHP中调用的函数中获取调用文件的绝对路径?
发布时间:2020-12-13 22:00:25 所属栏目:PHP教程 来源:网络整理
导读:在file.php中: call()... 如何在call()中获取file.php的绝对路径? 注意call()可以在另一个文件中定义. another.php: function call(){..} file.php: include(path_to_another.php);call(); 解决方法 没有办法除了 debug_backtrace function whatever() {
在file.php中:
call()... 如何在call()中获取file.php的绝对路径? 注意call()可以在另一个文件中定义. another.php: function call(){..} file.php: include(path_to_another.php); call(); 解决方法
没有办法除了
debug_backtrace
function whatever() { $t = debug_backtrace(); echo "called from {$t[0]['file']}"; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |