How can I check if the request was a POST or GET request in codeigniter?

I just wondered if there was a very simple way to determine if the request is a $_POST or $_GET request.

So Codeigniter has something like this?

 $this->container->isGet(); 
+5
source share
2 answers

I have never used codeigniter, but for this I am checking $_SERVER['REQUEST_METHOD'] .

Looking at the docs , maybe something like:

 if ($this->input->server('REQUEST_METHOD') == 'GET') //its a get else if ($this->input->server('REQUEST_METHOD') == 'POST') //its a post 

If you are going to use it a lot, then its easy to collapse your own isGet() function for it.

+20
source

For users CodeIgniter 3: status of docs> Input class has a function for receiving a request method:

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

Source: https://habr.com/ru/post/1205989/


All Articles