get_included_files

(PHP 4, PHP 5, PHP 7, PHP 8)

get_included_files返回被 include 和 require 文件名的 array

說(shuō)明

get_included_files(): array

返回所有被 include、 include_once、 requirerequire_once 的文件名。

返回值

返回所有文件名稱的 array。

腳本最初被稱為”被包含的文件“,所以腳本自身也會(huì)和 include 系列函數(shù)引用的腳本列在一起。

被多次 include 和 require 的文件在返回的 array 里只會(huì)列出一次。

范例

示例 #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";
}

?>

以上例程會(huì)輸出:

/path/to/abc.php
/path/to/test1.php
/path/to/test2.php
/path/to/test3.php
/path/to/test4.php

注釋

注意:

使用 auto_prepend_file 配置指令所包含的文件不會(huì)包含在返回的數(shù)組里。

參見(jiàn)