Php/docs/function.get-included-files

提供:Dev Guides
< Php
移動先:案内検索

get_included_files

(PHP 4, PHP 5, PHP 7)

get_included_filesinclude または require で読み込まれたファイルの名前を配列として返す


説明

get_included_files ( ) : array

この関数は、 includeinclude_oncerequire あるいは 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

参考