时间:2021-07-01 10:21:17 帮助过:3人阅读
比如说我在我的starphp框架里写一个文件,代码如下:
";echo "当前引入的文件";$files = get_included_files();print_r($files);然后去浏览器中执行url:http://localhost/starshop/index.php
那么输出的结果为:
当前用户定义的常量Array ( [ROOT] => D:\MyApp\wamp\www\starshop [D] => \ [STAR] => D:\MyApp\wamp\www\starshop\star [CORE] => D:\MyApp\wamp\www\starshop\star\core [HOST] => localhost [APP] => D:\MyApp\wamp\www\starshop\app [LOG] => D:\MyApp\wamp\www\starshop\app\data\log [MODULE] => D:\MyApp\wamp\www\starshop\app\index [VIEW] => D:\MyApp\wamp\www\starshop\app\index\view ) 当前引入的文件Array ( [0] => D:\MyApp\wamp\www\starshop\index.php [1] => D:\MyApp\wamp\www\starshop\star\star.php [2] => D:\MyApp\wamp\www\starshop\star\core\config.php [3] => D:\MyApp\wamp\www\starshop\star\core\fun.php [4] => D:\MyApp\wamp\www\starshop\star\core\core.php [5] => D:\MyApp\wamp\www\starshop\star\core\control.php [6] => D:\MyApp\wamp\www\starshop\app\index\control\index.c.php [7] => D:\MyApp\wamp\www\starshop\app\index\view\index.php )当然读者并没有我的starphp的源代码,不过不用着急,我只是给大家演示这两个函数的作用,大家可以用手头的框架去演示,看看到底引入了哪些文件和定义了哪些常量,还是蛮不错的。
下面是这些函数的说明:
get_defined_vars:获取用户定义的变量get_defined_functions:获取所有已定义的函数get_loaded_extensions:获取所有可用的模块get_extension_funcs($module_name):获取指定模块的可用函数get_defined_constants():获取所有常量get_declared_classes():获取已定义的类get_included_files():获取导入的文件