如何在CodeIgniter中检测HTTP方法

如何在CodeIgniter控制器类中检测HTTP方法?

编辑:除了在CodeIgniter中使用之外,还有其他方法吗?$_SERVER['REQUEST_METHOD']


答案 1

多亏了布兰登,我找到了答案。 与 相同。$this->input->server($index)$_SERVER[$index]

要获取方法,您可以使用:.$this->input->server('REQUEST_METHOD')

更新:(感谢Ecir Hana)

从CodeIgniter 3开始,也可以使用方法

echo $this->input->method(TRUE); // Outputs: POST
echo $this->input->method(FALSE); // Outputs: post
echo $this->input->method(); // Outputs: post

答案 2

在CodeIgniter 3中,您可以使用uhm...输入类的方法。

从文档中:

echo $this->input->method(TRUE); // Outputs: POST
echo $this->input->method(FALSE); // Outputs: post
echo $this->input->method(); // Outputs: post

推荐