查找打开的文件以生成PHP页面

时间:2012-12-04 20:58:32

标签: php joomla

我正在和一个烦人的复杂Joomla一起工作!站点,并且必须在代码级别对布局进行一些自定义。

我的问题是找到要编辑的文件。

因此,给定某个页面,我可以记录在解析期间打开的文件列表吗?

1 个答案:

答案 0 :(得分:4)

Tada,这是:http://de1.php.net/get+included+files get_included_files()

文档中关于仅获取直接包含文件的注释是错误的。无论您在何处调用该函数,都始终将所有文件包含在执行点中。

fileB.php
<?php
include 'fileB.php';

fileB.php
<?php
include 'fileC.php

fileC.php
<?php
var_dump(get_included_files());

输出:

array(3) {
  [0] =>
  string(18) "/path/to/fileA.php"
  [1] =>
  string(18) "/path/to/fileB.php"
  [2] =>
  string(18) "/path/to/fileC.php"
}

因此,如果您想知道所有文件,那么转储它们最好放在首先调用的文件的末尾,例如你通常的index.php