是否可以列出已包含的PHP文件以制作最终页面?

Flu*_*ffy 2 php include

假设有一个复杂的PHP脚本,其中包含许多其他PHP文件的动态包含.是否可以列出所有文件,这些文件已包含在PHP脚本的某个执行点中?

Sar*_*raz 9

当然,存在get_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";
}

?>
Run Code Online (Sandbox Code Playgroud)

结果如下:

abc.php
test1.php
test2.php
test3.php
test4.php
Run Code Online (Sandbox Code Playgroud)