394 of 410 menu

The get_included_files Function

The get_included_files function returns an array with the full paths of all files that have been included in the current script. This is useful for debugging when you need to check which files have actually been loaded.

Syntax

get_included_files();

Example

Let's check the list of included files in a simple script:

<?php include 'header.php'; require 'config.php'; $res = get_included_files(); print_r($res); ?>

Code execution result:

[ '/path/to/main.php', '/path/to/header.php', '/path/to/config.php' ]

Example

Let's check the number of included files:

<?php include 'functions.php'; include_once 'utils.php'; $res = count(get_included_files()); echo $res; ?>

Code execution result:

3

See Also

  • the print_r function,
    which prints information about a variable
  • the debug_backtrace function,
    which returns a backtrace
byenru