get_included_files可以以数组的形式显示目前引入的所有文件名称
<?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
本文通过一个简单的PHP示例展示了如何使用get_included_files()函数来获取当前脚本中所有被包含或所需的文件列表。该函数返回一个数组,包含了通过include、include_once、require或require_once等语句引入的所有文件路径。
1万+

被折叠的 条评论
为什么被折叠?



