Home > Backend Development > PHP Tutorial > PHP method to determine whether a file is imported get_included_files usage example

PHP method to determine whether a file is imported get_included_files usage example

黄舟
Release: 2023-03-06 06:56:02
Original
1562 people have browsed it

The example of this article describes the usage of get_included_files, the method of PHP to determine whether a file has been introduced. Share it with everyone for your reference, the details are as follows:

<?php
// 本文件是 abc.php
include &#39;test1.php&#39;;
include_once &#39;test2.php&#39;;
require &#39;test3.php&#39;;
require_once &#39;test4.php&#39;;
$included_files = get_included_files();
foreach ($included_files as $filename) {
  echo "$filename\n";
}
?>
Copy after login



Result:

The above routine will output:

abc.php
test1.php
test2.php
test3.php
test4.php
Copy after login



View the loading file of phpcms

D:\xampp\htdocs\duanzu\index.php
D:\xampp\htdocs\duanzu\phpcms\base.php
D:\xampp\htdocs\duanzu\phpcms\libs\functions\global.func.php
D:\xampp\htdocs\duanzu\phpcms\libs\functions\extention.func.php
D:\xampp\htdocs\duanzu\phpcms\libs\functions\autoload\plugin.func.php
D:\xampp\htdocs\duanzu\phpcms\libs\functions\autoload\video.func.php
D:\xampp\htdocs\duanzu\caches\configs\system.php
D:\xampp\htdocs\duanzu\phpcms\libs\classes\application.class.php
D:\xampp\htdocs\duanzu\phpcms\libs\classes\param.class.php
D:\xampp\htdocs\duanzu\caches\configs\route.php
D:\xampp\htdocs\duanzu\phpcms\modules\home\common.php
D:\xampp\htdocs\duanzu\phpcms\model\user_model.class.php
D:\xampp\htdocs\duanzu\phpcms\libs\classes\model.class.php
D:\xampp\htdocs\duanzu\phpcms\libs\classes\db_factory.class.php
D:\xampp\htdocs\duanzu\caches\configs\database.php
D:\xampp\htdocs\duanzu\phpcms\libs\classes\db_mysqli.class.php
D:\xampp\htdocs\duanzu\phpcms\libs\classes\sendsms.class.php
D:\xampp\htdocs\duanzu\phpcms\plugin\Taobao\TopSdk.php
D:\xampp\htdocs\duanzu\phpcms\plugin\Taobao\Autoloader.php
Copy after login

Be able to spy on the loading process of the project!

The above is the content of the get_included_files usage example of PHP's method to determine whether a file has been introduced. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template