I need some help for a problem i'm facing. I've look on the web but i only found more usual issues which cannot solve mine.
The main idea is to run PHP functions like get_included_files()
, get_defined_vars()
, debug_backtrace()
from the parent file.
In my code i have a PHP file, let's call it A.php which is including another PHP file, let's say B.php.
I would like to run for exemple get_included_files()
into B.php to get the files included in A.php.
Something similar to parent:: but for PHP files and not oriented object programming. I'm aware that it could be a security flaw, that's why i'm not sure it is possible, but i ask to be sure.
To be the clearest possible, here is an example :
A.php
include 'B.php';
include 'C.php';
include 'D.php';
get_includes();
B.php
function get_includes()
{
$included_files = get_included_files();
print_r($included_files);
}
And i need the $included_files
var to contain array('B','C','D')
.
My problem is the PHP functions getting the included files from the file it's launched in, not from the parent (with this code, the $included_files
is empty).
php is an interpreter, and interpretation will be strings. So the file a.php try to include files in the following order:
include 'С.php';
include 'D.php';
include 'B.php';