找出包含当前脚本的最后一个脚本的名称

发布于 2025-01-15 00:43:52 字数 287 浏览 4 评论 0原文

假设我有 3 个脚本,主/顶部脚本包括第二个脚本,而第二个脚本又包括第三个脚本。让我把它画出来,这样就清楚了。

[顶级脚本]-> [二级脚本]-> [第三级脚本]

那么,有没有一种简单的方法可以从第三级脚本获取“第二级脚本”的名称,也许有一些预定义的常量,第二级脚本包含的第三级脚本是否知道其父级?

请不要 SCRIPT_NAME 或 PHP_SELF 我,我知道它是什么,当我在最后包含的脚本中使用它时,它会显示“顶级脚本”的名称。我需要父母的名字,而不是祖父的名字!

Let's say I have 3 scripts, the main/top one which includes second which in turn includes a third. Let me draw that so it be clear.

[top level script] -> [second level script] -> [third level script]

So, is there a easy way to get a name of the "second level script" from the third, maybe there's some predefined constant, does the third script included by the second one know its parent?

Please don't SCRIPT_NAME or PHP_SELF me, I know what is it and when I use it inside of a last included script it shows me the name of the "top level script". I need the name of a parent, not a grandfather!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹短裙飘 2025-01-22 00:43:52

get_included_files 应该是有用。将以下代码放入 2 级或 3 级文件中:

$files = get_included_files();
list($parent) = array_slice($files, -2, 1);
echo $parent;

get_included_files should be useful. Place the following code in level 2 or level 3 file:

$files = get_included_files();
list($parent) = array_slice($files, -2, 1);
echo $parent;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文