Zend 框架:我可以只获取 GET 参数吗? [英] Zend Framework: Can i just get GET params?
本文介绍了Zend 框架:我可以只获取 GET 参数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Zend Framework 中,大部分时间我都会使用获取参数
In Zend Framework, most of the time to get a param, i will use
// from controller
$this->getRequest()->getParam('key');
但是我怎样才能使用Zend"方式获得 GET 参数?还是我只使用 $_GET
?
but how can i get just GET params using the 'Zend' way? Or do i just use $_GET
? Is there any difference between
$this->getRequest()->getParam('key');
对比
$_GET['key'];
推荐答案
使用 getQuery()
:
$this->_request->getQuery('key');
其他可用的方法包括
- getParam()
- getQuery()
- getPost()
- getCookie()
- getServer()
- getEnv()
getParam()
首先检查用户参数,然后是 $_GET,然后是 $_POST,返回找到的第一个匹配项或 null.
getParam()
checks user params first, then $_GET, and then $_POST, returning the first match found or null.
尽量避免直接访问超全局变量.
Try to avoid accessing the superglobals directly.
这篇关于Zend 框架:我可以只获取 GET 参数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文