get_included_files
get_included_files — includeまたはrequireで読み込まれたファイルの名前を配列として返す
説明
array get_included_files ( void )この関数は、include(), include_once(), require(), require_once()によりスクリプトにロードされた 全てのファイルの名前を配列として返します。
最初にコールされたスクリプトは "include されたファイル" という扱いに なります。そのため、include() やその仲間たちにより 読み込まれたファイルの一覧に含めて表示されます。
複数回読み込まれたファイルも返される配列には一度しかあらわれません。
注意: 設定ディレクティブauto_prepend_fileにより読み 込まれたファイルは、返される配列には含まれません。
例 1727. get_included_files() の例(abc.php)
<?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 4.0.1および以前のバージョンにおいて、 get_included_files()は、読み込まれるファイル が拡張子.phpで終ることを仮定しており、他の拡 張子のファイルは返されませんでした。 get_included_files()により返される配列は、連 想配列であり、include()および include_once()で読み込まれたファイルのみが一 覧に含まれていました。
include(), include_once(), require(), require_once(), get_required_files()も参照ください。
- get_included_files()のページへのリンク