助力软件开发企业降本增效 PHP / java源码系统,只需一次付费,代码终身使用! 广告
在运行时跟踪并转储文件包含和类继承的层次结构。 可以使用[include](https://www.php.net/manual/en/function.include.php),[include\_once](https://www.php.net/manual/en/function.include-once.php),[require](https://www.php.net/manual/en/function.require.php)或[require\_once](https://www.php.net/manual/en/function.require-once.php)[包括](https://www.php.net/manual/en/function.include.php)文件。 还报告了类继承依赖性 ## 要求 PHP版本5.1.0或更高版本。5.4+不再维护 随附的gengraph.php文件使用[»graphviz](http://www.graphviz.org/)库,但是,这不是必需的。 [https://pecl.php.net/package/inclued](https://pecl.php.net/package/inclued) 这些功能的行为受php.ini中的设置影响。 **包括配置选项** | 名称 | 默认 | 可修改范围 | 描述 | | --- | --- | --- | --- | |[inclued.enabled](https://www.php.net/manual/en/inclued.configuration.php#ini.inclued.enabled) | 关 | PHP\_INI\_SYSTEM |  是否启用包含。 | |[inclued.dumpdir](https://www.php.net/manual/en/inclued.configuration.php#ini.inclued.dumpdir) | **`NULL`** | PHP\_INI\_SYSTEM |  存储包含文件的目录的位置(路径)。如果设置,则每个PHP请求都将创建一个文件。这些文件是[inclued\_get\_data()](https://www.php.net/manual/en/function.inclued-get-data.php)会生成的序列化版本,因此可以使用unserialize()进行反序列化 因为每个请求都会创建一个文件,所以该目录可能会很快填满! | ## **inclued_get_data**(void):数组 **示例** ``` include 'x.php'; $clue = inclued_get_data(); print_r($clue); ``` 上面的示例将输出类似于以下内容的内容: ~~~ 数组 ( [includes] =>数组 ( [0] =>数组 ( [操作] =>包含 [op_type] => 2 [文件名] => x.php [opened_pa​​th] => /tmp/x.php [fromfile] => /tmp/z.php [fromline] => 2 ) ) ) ~~~ 有关使用此数据创建图形的方法,请参见下面的例子。 ## **实现包含在应用程序中的示例** 本示例演示了将其包含到现有应用程序中并查看结果的过程。 **Example#1在PHP应用程序本身中获取数据(函数)** ``` // File to store the inclued information $fp = fopen('/tmp/wp.ser', 'w'); if ($fp) {     $clue = inclued_get_data();     if ($clue) {         fwrite($fp, serialize($clue));     }     fclose($fp); } ``` 现在已经存在一些数据,现在该以图形的形式来理解它们了。包含的扩展名包括一个名为gengraph.php的PHP文件,该文件创建一个需要[»graphviz](http://www.graphviz.org/)库的点文件。但是,此表格不是必需的。 **Example#2 gengraph.php使用示例** 本示例创建一个名为inclued.png的图像,其中显示了包含的数据。 ~~~ #首先,创建点文件 $ php gengraph.php -i /tmp/wp.ser -o wp.dot #接下来,创建图像 $ dot -Tpng -o inclued.png wp.dot ~~~ **Example#3通过包含的转储列出数据(配置)** 当使用[inclued.dumpdir](https://www.php.net/manual/en/inclued.configuration.php#ini.inclued.dumpdir)指令时,每个请求都将转储文件(包括线索)。这是列出这些文件并反[序列化()](https://www.php.net/manual/en/function.unserialize.php)的一种方法。 ``` $path = ini_get('inclued.dumpdir'); if ($path && is_dir($path)) {     echo "Path: $path", PHP_EOL;     $inclues = new GlobIterator($path . DIRECTORY_SEPARATOR . 'inclued*');     if ($inclues->count() === 0) {         echo 'No clues today', PHP_EOL;         exit;     }     foreach ($inclues as $inclue) {         echo 'Inclued file: ', $inclue->getFilename(), PHP_EOL;         $data = file_get_contents($inclue->getPathname());         if ($data) {             $inc = unserialize($data);             echo ' -- filename: ', $inc['request']['SCRIPT_FILENAME'], PHP_EOL;             echo ' -- number of includes: ', count($inc['includes']), PHP_EOL;         }         echo PHP_EOL;     } } else {     echo 'I am totally clueless today.', PHP_EOL; } ``` 上面的示例将输出类似于以下内容的内容: ~~~ 路径:/ tmp /包含 包含的文件:includ.56521.1 -文件名:/Users/philip/test.php -包含的数量:1 包含的文件:includ.56563.1 -文件名:/tmp/none.php -包含的数量:0 包含的文件:incleded.56636.1 -文件名:/tmp/three.php -数量包括:3 ~~~