How to get the names of all included or required files in PHP

3 Answers

0 votes
echo "<pre>";
echo print_r(get_included_files());
echo "</pre>";


/*
run:

Array
(
    [0] => C:\xampp\htdocs\webshopy.com\test.php
)
1

*/

 



answered Jun 22, 2016 by avibootz
0 votes
include 'test1.php';
include_once 'test2.php';
require 'test3.php';
require_once 'test4.php';

echo "<pre>";
echo print_r(get_included_files());
echo "</pre>";


/*
run:

Array
(
    [0] => C:\xampp\htdocs\webshopy.com\test.php
    [1] => C:\xampp\htdocs\webshopy.com\test1.php
    [2] => C:\xampp\htdocs\webshopy.com\test2.php
    [3] => C:\xampp\htdocs\webshopy.com\test3.php
    [4] => C:\xampp\htdocs\webshopy.com\test4.php
)
1


*/

 



answered Jun 22, 2016 by avibootz
0 votes
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 <br />";


/*
run:

C:\xampp\htdocs\webshopy.com\test.php 
C:\xampp\htdocs\webshopy.com\test1.php 
C:\xampp\htdocs\webshopy.com\test2.php 
C:\xampp\htdocs\webshopy.com\test3.php 
C:\xampp\htdocs\webshopy.com\test4.php 

*/

 



answered Jun 22, 2016 by avibootz
...