快速区分PHP中的函数与结构
浏览:2366次 出处信息
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 (阅读:8044)
- 不定参数的应用 function(fmt, …) (阅读:4017)
- 函数式编程 (阅读:3691)
- JavaScript的5种调用函数的方法 (阅读:3650)
- C 语言中统一的函数指针 (阅读:3049)
- C语言函数实现的另类方法 (阅读:2924)
- 关于在函数调用时传递string引用的必要性 (阅读:2857)
- 浏览器的结构 (阅读:2722)
- 深入理解PHP之匿名函数 (阅读:2614)
- MySQL 内部函数简介 (阅读:2459)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
扫一扫订阅我的微信号:IT技术博客大学习
后一篇:PHP 中关于资源的释放 >>
文章信息
- 作者:phpor <lijunjie1982@yahoo.com.cn> 来源: PHPor 的blog
- 标签: 函数 结构
- 发布时间:2011-03-27 23:56:39
建议继续学习
近3天十大热文
- [71] Twitter/微博客的学习摘要
- [65] IOS安全–浅谈关于IOS加固的几种方法
- [64] find命令的一点注意事项
- [64] android 开发入门
- [62] 如何拿下简短的域名
- [62] Go Reflect 性能
- [60] Oracle MTS模式下 进程地址与会话信
- [60] 流程管理与用户研究
- [57] 图书馆的世界纪录
- [57] 读书笔记-壹百度:百度十年千倍的29条法则