是否可以列出已包含在最终页面中的 PHP 文件?

发布于 2024-10-08 17:20:49 字数 73 浏览 0 评论 0原文

假设有一个复杂的 PHP 脚本,其中包含许多其他 PHP 文件的动态包含。是否可以列出 PHP 脚本执行某个时刻之前包含的所有文件?

Say there is a complex PHP script with a lot of dynamic inclusions of other PHP files. Is it possible to list all the files, that have been included up to a certain point of execution of a PHP script?

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

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

发布评论

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

评论(2

南巷近海 2024-10-15 17:20:49

当然,存在 get_included_files 函数。

示例:

<?php
// This file is abc.php

include 'test1.php';
include_once 'test2.php';
require 'test3.php';
require_once 'test4.php';

$included_files = get_included_files();

foreach ($included_files as $filename) {
    echo "$filename\n";
}

?>

结果将类似于:

abc.php
test1.php
test2.php
test3.php
test4.php

Sure, there exists get_included_files function for that.

Example:

<?php
// This file is abc.php

include 'test1.php';
include_once 'test2.php';
require 'test3.php';
require_once 'test4.php';

$included_files = get_included_files();

foreach ($included_files as $filename) {
    echo "$filename\n";
}

?>

Result will be like:

abc.php
test1.php
test2.php
test3.php
test4.php
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文