Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: List all includes

Tags:

php

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?

like image 779
Liam Avatar asked Aug 20 '09 16:08

Liam


People also ask

What does include() do in PHP?

PHP Include Files. The include (or require ) statement takes all the text/code/markup that exists in the specified file and copies it into the file that uses the include statement. Including files is very useful when you want to include the same PHP, HTML, or text on multiple pages of a website.

How to check included file in PHP?

Calling get_included_files() returns an array containing all the included files whether they were included with the include() include_once() require() or require_once() functions.


1 Answers

register_shutdown_function(
    function() {
        your_logger(get_included_files());
    }
);

get_included_files will be called at the end of script execution, so u`ll get full list of included files

like image 145
Maxim Grizik Avatar answered Oct 20 '22 17:10

Maxim Grizik