How can I check if request was a POST or GET request in codeigniter?
For CodeIgniter 3 users: the docs state the input class has a function to get the request method:
echo $this->input->method(TRUE); // Outputs: POST
echo $this->input->method(FALSE); // Outputs: post
echo $this->input->method(); // Outputs: post
I've never used codeigniter, but for this I check the $_SERVER['REQUEST_METHOD']
.
Looking at the docs maybe something like:
if ($this->input->server('REQUEST_METHOD') === 'GET') {
//its a get
} elseif ($this->input->server('REQUEST_METHOD') === 'POST') {
//its a post
}
If you're going to use it a lot then it's simple to roll your own isGet()
function for it.