array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), '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' => 'ja', '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 で読み込まれたファイルの名前を配列として返す
この関数は、 include、include_once、 require あるいは require_once によりスクリプトにロードされたすべてのファイルの名前を取得します。
この関数にはパラメータはありません。
すべてのファイル名を含む配列を返します。
最初にコールされたスクリプトは "include されたファイル" という扱いに なります。そのため、 include やその仲間たちにより 読み込まれたファイルの一覧に含めて表示されます。
複数回読み込まれているファイルも、 返される配列には一度しかあらわれません。
例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