Fungsi get_included_files

Fungsi get_included_files mengembalikan array dengan path lengkap semua file, yang telah disertakan dalam skrip saat ini. Ini berguna untuk debugging ketika perlu memeriksa file mana saja yang benar-benar telah dimuat.

Sintaks

phpget_included_files();

Contoh

Mari periksa daftar file yang disertakan dalam skrip sederhana:

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

Hasil eksekusi kode:

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

Contoh

Mari periksa jumlah file yang disertakan:

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

Hasil eksekusi kode:

php3

Lihat juga

  • fungsi print_r,
    yang mencetak informasi tentang variabel
  • fungsi debug_backtrace,
    yang mengembalikan jejak panggilan stack