Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,940 questions

51,877 answers

573 users

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

Related questions

1 answer 139 views
1 answer 156 views
1 answer 150 views
1 answer 159 views
1 answer 151 views
...