• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php如何输出所有变量/常量/模块/函数/类代码详解

php 搞代码 4年前 (2022-01-22) 11次浏览 已收录 0个评论

PHP输出当前进程所有变量、常量、模块、函数、类的示例

1. get_defined_vars (PHP 4 >= 4.0.4, PHP 5) — 获取由所有已定义变量所组成的数组
array get_defined_vars ( void )
此函数返回一个包含所有已定义变量列表的多维数组,这些变量包括环境变量、服务器变量和用户定义的变量。

<?phpecho '<pre>';$b = array(1,1,2,3,5,8);$arr = get_defined_vars();// 打印 $bprint_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 表示为空,不需要任何参数

<?phpecho '<pre>';function foo(){    echo "This is my function foo";}$arr = get_defined_functions();print_r($arr);?>

3. get_loaded_extensions (PHP 4, PHP 5) — 获取所有可用的模块

<?phpecho '<pre>';print_r(get_loaded_extensions());?>

4. get_extension_funcs (PHP 4, PHP 5) — 获取指定模块的可用函数
array get_extension_funcs ( string $module_name ) 该函数返回指定模块所有可用的函数。传入的参数(模块名称)必须是小写

<?phpecho '<pre>';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 ] )

<?phpecho '<pre>';define("MY_CO<em style="color:transparent">本@文来源[email protected]搞@^&代*@码网(</em><q>搞代gaodaima码</q>NSTANT", 1);print_r(get_defined_constants(true));?>

6. get_declared_classes (PHP 4, PHP 5) — 获取由已定义类的名字所组成的数组
array get_declared_classes ( void )

<?phpecho '<pre>';//define classoneclass classone { }//define classtwoclass classtwo { }//This will show X classes (built-ins, extensions etc) with//classone and classtwo as the last two elementsprint_r(get_declared_classes());//define classthreeclass classthree { }//...and fourclass classfour { }//Shows the same result as before with class three and four appendedprint_r(get_declared_classes());?>

以上就是php如何输出所有变量/常量/模块/函数/类代码详解的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php如何输出所有变量/常量/模块/函数/类代码详解

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址