get_required_files

(PHP4 >= 4.0RC2)

get_required_files --  Returns an array with the names of the files require_once()'d in a script

Description

array get_required_files (void)

This function returns an associtative array of the names of all the files that have been loaded into a script using require_once(). The indexes of the array are the file names as used in the require_once() without the ".php" extension.

The example below

Example 1. Printing the required and included files


<?php

require_once ("local.php");
require_once ("../inc/global.php");

for ($i=1; $i<5; $i++)
    include "util".$i."php";

echo "Required_once files\n";
print_r (get_required_files());

echo "Included_once files\n";
print_r (get_included_files());
?>
      
will generate the following output:


Required_once files
Array
(
    [local] => local.php 
    [../inc/global] => /full/path/to/inc/global.php
)

Included_once files
Array
(
    [util1] => util1.php 
    [util2] => util2.php 
    [util3] => util3.php 
    [util4] => util4.php 
)
      

Note: As of PHP 4.0.1pl2 this function assumes that the required_once files end in the extension ".php", other extensions do not work.

See also: require_once(), include_once(), get_included_files()


Hosted by Tonec Inc.