快速区分PHP中的函数与结构
浏览:2319次 出处信息
PHP中有些类似于函数的东西其实不是函数,如 echo exit unset print 等。 怎么可以快速知道这些是函数还是结构呢?
测试脚本:
执行脚本: php test.php
如果被解析为 307 就是函数,否则就可能是结构(或别的什么)。
{当然您也可以直接查手册,手册中基本会提到的}
---------------------------------------
Array
(
[0] => Array
(
[0] => 367
[1] => <?php
)
[1] => Array
(
[0] => 307
[1] => print_r
)
[2] => (
[3] => Array
(
[0] => 307
[1] => token_get_all
)
[4] => (
[5] => Array
(
[0] => 307
[1] => file_get_contents
)
[6] => (
[7] => Array
(
[0] => 364
[1] => __FILE__
)
[8] => )
[9] => )
[10] => )
[11] => ;
[12] => Array
(
[0] => 370
[1] =>
)
[13] => Array
(
[0] => 266
[1] => print
)
[14] => Array
(
[0] => 370
[1] =>
)
[15] => Array
(
[0] => 315
[1] => ""
)
[16] => ;
[17] => Array
(
[0] => 370
[1] =>
)
[18] => Array
(
[0] => 316
[1] => echo
)
[19] => Array
(
[0] => 370
[1] =>
)
[20] => Array
(
[0] => 315
[1] => ""
)
[21] => ;
[22] => Array
(
[0] => 370
[1] =>
)
[23] => Array
(
[0] => 348
[1] => unset
)
[24] => (
[25] => Array
(
[0] => 309
[1] => $a
)
[26] => )
[27] => ;
[28] => Array
(
[0] => 370
[1] =>
)
[29] => Array
(
[0] => 300
[1] => exit
)
----------------------------------------------------
测试脚本:
PHP中的函数与结构 test.php
-
<?php
-
print_r(token_get_all(file_get_contents(__FILE__)));
-
print "";
-
echo "";
-
unset($a);
-
exit;
执行脚本: php test.php
如果被解析为 307 就是函数,否则就可能是结构(或别的什么)。
{当然您也可以直接查手册,手册中基本会提到的}
---------------------------------------
Array
(
[0] => Array
(
[0] => 367
[1] => <?php
)
[1] => Array
(
[0] => 307
[1] => print_r
)
[2] => (
[3] => Array
(
[0] => 307
[1] => token_get_all
)
[4] => (
[5] => Array
(
[0] => 307
[1] => file_get_contents
)
[6] => (
[7] => Array
(
[0] => 364
[1] => __FILE__
)
[8] => )
[9] => )
[10] => )
[11] => ;
[12] => Array
(
[0] => 370
[1] =>
)
[13] => Array
(
[0] => 266
[1] => print
)
[14] => Array
(
[0] => 370
[1] =>
)
[15] => Array
(
[0] => 315
[1] => ""
)
[16] => ;
[17] => Array
(
[0] => 370
[1] =>
)
[18] => Array
(
[0] => 316
[1] => echo
)
[19] => Array
(
[0] => 370
[1] =>
)
[20] => Array
(
[0] => 315
[1] => ""
)
[21] => ;
[22] => Array
(
[0] => 370
[1] =>
)
[23] => Array
(
[0] => 348
[1] => unset
)
[24] => (
[25] => Array
(
[0] => 309
[1] => $a
)
[26] => )
[27] => ;
[28] => Array
(
[0] => 370
[1] =>
)
[29] => Array
(
[0] => 300
[1] => exit
)
----------------------------------------------------
建议继续学习:
- 解剖CPU (阅读:8024)
- 不定参数的应用 function(fmt, …) (阅读:3995)
- 函数式编程 (阅读:3675)
- JavaScript的5种调用函数的方法 (阅读:3599)
- C 语言中统一的函数指针 (阅读:3030)
- C语言函数实现的另类方法 (阅读:2907)
- 关于在函数调用时传递string引用的必要性 (阅读:2839)
- 浏览器的结构 (阅读:2709)
- 深入理解PHP之匿名函数 (阅读:2591)
- MySQL 内部函数简介 (阅读:2442)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
扫一扫订阅我的微信号:IT技术博客大学习
后一篇:PHP 中关于资源的释放 >>
文章信息
- 作者:phpor <lijunjie1982@yahoo.com.cn> 来源: PHPor 的blog
- 标签: 函数 结构
- 发布时间:2011-03-27 23:56:39
建议继续学习
近3天十大热文
- [55] Oracle MTS模式下 进程地址与会话信
- [55] IOS安全–浅谈关于IOS加固的几种方法
- [54] 如何拿下简短的域名
- [53] android 开发入门
- [52] Go Reflect 性能
- [51] 图书馆的世界纪录
- [49] 读书笔记-壹百度:百度十年千倍的29条法则
- [47] 【社会化设计】自我(self)部分――欢迎区
- [38] 程序员技术练级攻略
- [33] 视觉调整-设计师 vs. 逻辑