PHP输出当前进程所有变量 / 常量 / 模块 / 函数 / 类
2015-10-19 16:17
651 查看
1. get_defined_vars (PHP 4 >= 4.0.4, PHP 5) — 获取由所有已定义变量所组成的数组
array get_defined_vars ( void )此函数返回一个包含所有已定义变量列表的多维数组,这些变量包括环境变量、服务器变量和用户定义的变量。
<?php echo '<pre>'; $b = array(1,1,2,3,5,8); $arr = get_defined_vars(); // 打印 $b print_r($arr["b"]); // 打印所有服务器变量 print_r($arr["_SERVER"]); // 打印变量数组的所有可用键值 print_r(array_keys(get_defined_vars())); ?>
2. get_defined_functions (PHP 4 >= 4.0.4, PHP 5) — 获取所有已经定义的函数
array get_defined_functions ( void ) //void 表示为空,不需要任何参数
<?php echo '<pre>'; function foo() { echo "This is my function foo"; } $arr = get_defined_functions(); print_r($arr); ?>
3. get_loaded_extensions (PHP 4, PHP 5) — 获取所有可用的模块
<?php echo '<pre>'; print_r(get_loaded_extensions()); ?>
4. get_extension_funcs (PHP 4, PHP 5) — 获取指定模块的可用函数
<?php echo '<pre>'; //array get_extension_funcs ( string $module_name ) 该函数返回指定模块所有可用的函数。传入的参数(模块名称)必须是小写 print_r(get_extension_funcs("gd")); print_r(get_extension_funcs("xml")); ?>
5. get_defined_constants (PHP 4 >= 4.1.0, PHP 5) — 获取关联数组的名字所有的常量和他们的价值
array get_defined_constants ([ bool
$categorize= false ] )
<?php echo '<pre>'; define("MY_CONSTANT", 1); print_r(get_defined_constants(true)); ?>
6. get_declared_classes (PHP 4, PHP 5) — 获取由已定义类的名字所组成的数组
array get_declared_classes ( void )
<?php echo '<pre>'; //define classone class classone { } //define classtwo class classtwo { } //This will show X classes (built-ins, extensions etc) with //classone and classtwo as the last two elements print_r(get_declared_classes()); //define classthree class classthree { } //...and four class classfour { } //Shows the same result as before with class three and four appended print_r(get_declared_classes()); ?>
7. get_included_files()(或者get_require_files) (PHP 4, PHP 5) — 获取由已定义类的名字所组成的数组
<?php // This file is abc.php include 'test1.php'; include_once 'test2.php'; require 'test3.php'; require_once 'test4.php'; $included_files = get_included_files(); foreach ($included_files as $filename) { echo "$filename\n"; } ?>
相关文章推荐
- php比较加赋值语句
- php实现新浪微博第三方信任登录
- yaf在windows7下32位的安装教程
- php之茴字写法
- 根据IP地址获取所在城市
- php对象在内存中存在形式
- php模拟post提交数据
- php 堆排序
- RTP 协议分析
- 简单的PHP异常处理
- Smarty赋值对象方法,配置简化封装类
- 部署PHP时的4个配置修改说明
- 听韩顺平聊PHP初学者如何变身大牛
- php 抓取中国统计局 最新县及县以上行政区划代码
- Github比较有趣的PHP项目
- phpstorm9.02 下载
- ContentProvider
- 访问phpmyadmin提示没有权限
- PHP中empty()和isset()的区别
- PHP 7 vs HHVM 比较—兄弟连IT教育