Sgn*_*gn. 35 php codeigniter http-method codeigniter-2
如何在CodeIgniter控制器类中检测HTTP方法?
编辑:
除了$_SERVER['REQUEST_METHOD']在CodeIgniter中使用之外还有其他方法吗?
Sgn*_*gn. 59
感谢Branden,我找到了答案.
$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
Run Code Online (Sandbox Code Playgroud)
Eci*_*ana 17
在CodeIgniter 3中,您可以使用输入类的方法 uhm ...方法.
来自文档:
echo $this->input->method(TRUE); // Outputs: POST
echo $this->input->method(FALSE); // Outputs: post
echo $this->input->method(); // Outputs: post
Run Code Online (Sandbox Code Playgroud)
您可以使用输入库检测GET和POST.
$this->input->post() 要么 $this->input->get()
可以找到更多信息:http://ellislab.com/codeigniter%20/user-guide/libraries/input.html
| 归档时间: |
|
| 查看次数: |
38146 次 |
| 最近记录: |