是否有一个魔术变量可以为我提供包含脚本的名称?
示例:
<?php
include_once('test.php');
<?php
// Prints test.php
echo ___INCLUDING___;
答案 0 :(得分:0)
来自an answer to Stack Overflow question Get name of file that is including a PHP script:
<?php
$trace = debug_backtrace();
if (isset($trace[0])) {
$includingScript = basename($trace[0]['file']);
echo $includingScript;
}
?>