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

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

php 搞代码 3年前 (2022-01-25) 24次浏览 已收录 0个评论

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

<?php<BR>echo '<pre class="prettyprint linenums">';<BR>$b = array(1,1,2,3,5,8);<BR>$arr = get_defined_vars();<BR>// 打印 $b<BR>print_r($arr["b"]);<BR>// 打印所有服务器变量<BR>print_r($arr["_SERVER"]);<BR>// 打印变量数组的所有可用键值<BR>print_r(array_keys(get_defined_vars()));<BR>?><BR><STRONG>2. get_defined_functions</STRONG> (PHP 4 >= 4.0.4, PHP 5) — 获取所有已经定义的函数<BR>array get_defined_functions ( void ) //void 表示为空,不需要任何参数<BR><?php<BR>echo '<pre class="prettyprint linenums">';<BR>function foo()<BR>{<BR>    echo "This is my function foo";<BR>}<BR>$arr = get_defined_functions();<BR>print_r($arr);<BR>?><BR>


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

<?php<BR>echo '<pre class="prettyprint linenums">';<BR>print_r(get<em style="color:transparent">本文来源gao.dai.ma.com搞@代*码#网</em><a>搞代gaodaima码</a>_loaded_extensions());<BR>?><BR>


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

<?php<BR>echo '<pre class="prettyprint linenums">';<BR>print_r(get_extension_funcs("gd"));<BR>print_r(get_extension_funcs("xml"));<BR>?><BR>


5. get_defined_constants (PHP 4 >= 4.1.0, PHP 5) — 获取关联数组的名字所有的常量和他们的价值
array get_defined_constants ([ bool $categorize = false ] )

<?php<BR>echo '<pre class="prettyprint linenums">';<BR>define("MY_CONSTANT", 1);<BR>print_r(get_defined_constants(true));<BR>?><BR>


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

<?php<BR>echo '<pre class="prettyprint linenums">';<BR>//define classone<BR>class classone { }<BR>//define classtwo<BR>class classtwo { }<BR>//This will show X classes (built-ins, extensions etc) with<BR>//classone and classtwo as the last two elements<BR>print_r(get_declared_classes());<BR>//define classthree<BR>class classthree { }<BR>//...and four<BR>class classfour { }<BR>//Shows the same result as before with class three and four appended<BR>print_r(get_declared_classes());<BR>?><BR>

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

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

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

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