I have a large complex PHP project made up of many PHP files.
Is there some function I can call in my code that will return a list of all included files?
I have a large complex PHP project made up of many PHP files.
Is there some function I can call in my code that will return a list of all included files?
get_included_files
or get_required_files
(alias of get_included_files
)
http://us.php.net/manual/en/function.get-included-files.php
http://us.php.net/manual/en/function.get-required-files.php (Alias of 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";
}
?>
-----
The above example will output:
abc.php
test1.php
test2.php
test3.php
test4.php
Is there a way to get the same functionality but calling it from another page? An example would be if this function actually took an argument that consisted of another PHP file.
I found a work around for my problem. I wrote function that wrote all the results into a file with the same name into another directory using this function. I included this file with the function on every page of the web site using an htaccess file with the php_value auto_prepend_file filename.php. I then wrote an another app to read these files to calculate the metrics.