get_included_files
(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
註釋
注意:
使用
auto_prepend_file
配置指令所包含的檔案不會包含在返回的陣列里。
參見
- include - include
- include_once - include_once
- require - require
- require_once - require_once
- get_required_files() - 別名 get_included_files