如何查找由(相对路径)require()加载的文件,而无需查看include_path中的所有文件夹


How to find which file is being loaded by a (relative path) require() without looking through all the folders in the include_path

我在多台服务器上安装了一个脚本,第一行是:

require_once 'MDB2.php';

在某些服务器上,从某个共享文件夹中找到了该文件,但在其他服务器上没有找到该文件。是否有任何快速的方法来记录或输出哪些文件(即它们所在的文件夹)正在被一个require或include调用加载,而不必确定include_path值并通过该值指定的所有文件夹进行搜索?

根据PHP站点上的include文档,似乎没有比以下方法更快的方法了:

<?php
function include_which($filename) {
    $dirs = explode(':', ini_get('include_path'));
    foreach ($dirs as $dir) {
        if (is_file("{$dir}/{$filename}")) {
            return "{$dir}/{$filename}";
        }
    }
}