Friday, October 3, 2025
HomeLanguagesPHP get_included_files() Function

PHP get_included_files() Function

The get_included_files() is an inbuilt function that returns an array with names of included or required files.

Syntax:

get_included_files(): array 

Parameters: This function does not accept any parameters.

Return Values: It returns an array of the names of files.

Example 1:  This example demonstrates the get_included_files() function.

PHP




<?php
include 'print.php';  
$nameFile =  get_included_files() ;
var_dump($nameFile) ;
?>


Note: The included file has to be present in the correct directory. In this example, it’s  ‘print.php’.

Output:

array(2) {
    [0] => string(51) “/home/dachman/Desktop/Articles/GFG/Method/index.php”
    [1] => string(51) “/home/dachman/Desktop/Articles/GFG/Method/print.php”
}

Example 2: The following code also demonstrates the get_included_files() function.

Note: The output this these programs must be different according to your system path or where you store your files.

PHP




<?php
  
  include 'print.php';
      
$nameFile =  get_included_files() ;
foreach($nameFile as $filename){
    echo $filename."\n" ;
}
  
?>


Output:

/home/dachman/Desktop/Articles/GFG/Method/index.php
/home/dachman/Desktop/Articles/GFG/Method/print.php

Reference: https://www.php.net/manual/en/function.get-included-files.php

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32332 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11868 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11929 POSTS0 COMMENTS
Shaida Kate Naidoo
6819 POSTS0 COMMENTS
Ted Musemwa
7080 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS