我只是想知道是否有一种非常简单的方法来确定请求是$_POST还是$_GET请求。那么Codeigniter有这样的东西吗?
$_POST
$_GET
Codeigniter
$this->container->isGet();
aemubtdh1#
我从来没有使用过codeigniter,但对于这个,我检查了$_SERVER['REQUEST_METHOD']。看一下the docs,可能类似于:
$_SERVER['REQUEST_METHOD']
if ($this->input->server('REQUEST_METHOD') === 'GET') { //its a get } elseif ($this->input->server('REQUEST_METHOD') === 'POST') { //its a post }
如果你要经常使用它,那么为它滚动你自己的isGet()函数是很简单的。
isGet()
a5g8bdjr2#
对于CodeIgniter 3用户:docs声明输入类具有获取请求方法的函数:
echo $this->input->method(TRUE); // Outputs: POST echo $this->input->method(FALSE); // Outputs: post echo $this->input->method(); // Outputs: post
sycxhyv73#
在代码点火器4中:
$this->request->getMethod() // Returns get, post, or whatever the method is
cigdeys34#
正确答案是:
if ($this->input->post()) { //have post }
4条答案
按热度按时间aemubtdh1#
我从来没有使用过codeigniter,但对于这个,我检查了
$_SERVER['REQUEST_METHOD']
。看一下the docs,可能类似于:
如果你要经常使用它,那么为它滚动你自己的
isGet()
函数是很简单的。a5g8bdjr2#
对于CodeIgniter 3用户:docs声明输入类具有获取请求方法的函数:
sycxhyv73#
在代码点火器4中:
cigdeys34#
正确答案是: