Funktionen get_included_files

Funktionen get_included_files returnerar en array med fullständiga sökvägar till alla filer som har inkluderats i det aktuella skriptet. Detta är användbart för felsökning när det är nödvändigt att kontrollera vilka filer som verkligen har laddats.

Syntax

phpget_included_files();

Exempel

Låt oss kontrollera listan över inkluderade filer i ett enkelt skript:

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

Resultat av kodkörning:

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

Exempel

Låt oss kontrollera antalet inkluderade filer:

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

Resultat av kodkörning:

php3

Se även

  • funktionen print_r,
    som skriver ut information om en variabel
  • funktionen debug_backtrace,
    som returnerar anropsstacken