PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

get_included_files - include または require で読み込まれたファイルの名前を配列として返す | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

get_included_files

(PHP 4, PHP 5, PHP 7)

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

説明

array get_included_files ( void )

この関数は、 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

注意

注意:

設定ディレクティブ auto_prepend_file で読み込まれたファイルは、返される配列には含まれません。

参考


忘却曲線を使ってこの関数を確実に記憶に残す

フォーラムで「get_included_files - include または require で読み込まれたファイルの名前を配列として返す」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | get_included_files - include または require で読み込まれたファイルの名前を配列として返す」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: