array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.get-included-files.php', 1 => 'get_included_files', ), 'up' => array ( 0 => 'ref.info.php', 1 => 'PHP 选项/信息 函数', ), 'prev' => array ( 0 => 'function.get-include-path.php', 1 => 'get_include_path', ), 'next' => array ( 0 => 'function.get-loaded-extensions.php', 1 => 'get_loaded_extensions', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/info/functions/get-included-files.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
get_included_files — 返回被 include 和 require 文件名的 array
此函数没有参数。
返回所有文件名称的 array。
脚本最初被称为”被包含的文件“,所以脚本自身也会和 include 系列函数引用的脚本列在一起。
被多次 include 和 require 的文件在返回的 array 里只会列出一次。
示例 #1 get_included_files() 示例
<?php
// 本文件是 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";
}
?>
以上示例会输出:
/path/to/abc.php /path/to/test1.php /path/to/test2.php /path/to/test3.php /path/to/test4.php