How to detect HTTP method in CodeIgniter

前端 未结 3 1351
离开以前
离开以前 2020-12-28 13:04

How can I detect HTTP method in CodeIgniter controller class?

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

3条回答
  •  没有蜡笔的小新
    2020-12-28 13:46

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

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

    UPDATE: (thanks to Ecir Hana)

    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
    

提交回复
热议问题