PHP:列出所有包含

时间:2009-08-20 16:30:21

标签: php

我有一个由许多PHP文件组成的大型复杂PHP项目。

我可以在我的代码中调用一些函数来返回所有包含文件的列表吗?

3 个答案:

答案 0 :(得分:21)

get_included_filesget_required_files(别名get_included_files

http://us.php.net/manual/en/function.get-included-files.php
http://us.php.net/manual/en/function.get-required-files.phpget_included_files的别名)

<?php
// This file is 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";
}
?>

-----
The above example will output:

abc.php
test1.php
test2.php
test3.php
test4.php

答案 1 :(得分:2)

register_shutdown_function(
    function() {
        your_logger(get_included_files());
    }
);

get_included_files将在脚本执行结束时调用,因此你将获得包含文件的完整列表

答案 2 :(得分:1)

相关问题