一段精妙的代码,反应了无尽的智慧
2008-07-21 10:49
225 查看
解读zf getPost
别看这个小小的函数,却提供了很多可变的功能
/**
* Retrieve a member of the $_POST superglobal
*
* If no $key is passed, returns the entire $_POST array.
*
* @todo How to retrieve from nested arrays
* @param string $key
* @param mixed $default Default value to use if key not found
* @return mixed Returns null if key does not exist
*/
public function getPost($key = null, $default = null)
{
if (null === $key) {
return $_POST;
}
return (isset($_POST[$key])) ? $_POST[$key] : $default;
}
1.获取全局的$_POST
2.返回相应key的POST
3.设置相应key的默认POST
4.注意isset函数,说明了其代码的严谨性
相关文章推荐
- 有没有一段代码,让你觉得人类的智慧也可以璀璨无比?
- 神一样的一段代码与人类智慧
- 有没有一段代码,让你觉得人类的智慧也可以璀璨无比?【转】
- 一段精妙的参数检查代码
- 有没有一段代码,让你觉得人类的智慧也可以璀璨无比?
- 有没有一段代码,让你觉得人类的智慧也可以璀璨无比?
- 有没有一段代码,让你觉得人类的智慧也可以璀璨无比?
- 有没有一段代码,让你觉得人类的智慧也可以璀璨无比?
- 一段很精妙的类协程代码
- 你碰到过双击exe文件或桌面快捷方式没反应的情况吗;一段代码解决问题:
- 有没有一段代码,让你觉得人类的智慧也可以璀璨无比?
- vim 自动补全一段代码
- 手机端测试touch的一段代码
- 一段代码:一九九七年世界编程大赛冠军作品
- 一段用来清除C++/C代码中空白行的perl脚本
- #ifdef __cplusplus extern "C" { #endif //一段代码 #ifdef __cplusplus } #endif
- 网上找了一段代码,利用MemoryStream来存储分块的数据包,将其转换成为byte[]后,所有字节都为0.找到问题了。
- 一段代码得到本页面的文件名
- opengl笔记——旋转,一段代码的理解
- 今天我看到一段代码!!!神一样的代码,欢迎大家吐槽!!!