如何检测CodeIgniter中的HTTP方法 [英] How to detect HTTP method in CodeIgniter

查看:125
本文介绍了如何检测CodeIgniter中的HTTP方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I detect HTTP method in CodeIgniter controller class?

编辑:
是否有其他方法, code> $ _ SERVER ['REQUEST_METHOD'] 在CodeIgniter?

Edited: Is there any other way than using $_SERVER['REQUEST_METHOD'] in CodeIgniter?

推荐答案

,我找到了答案。
$ this-> input-> server($ index) $ _ SERVER [$ index]

Thanks to Branden, I've found the answer. $this->input->server($index) is identical to $_SERVER[$index].

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

To get method you can use: $this->input->server('REQUEST_METHOD').

更新:(感谢 Ecir Hana

从CodeIgniter 3开始,使用方法

As of CodeIgniter 3, using of method is also possible:

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

这篇关于如何检测CodeIgniter中的HTTP方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆