Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

So does Codeigniter have something like this?

$this->container->isGet();
like image 210
hecontreraso Avatar asked Oct 31 '14 20:10

hecontreraso


1 Answers

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.

like image 65
cOle2 Avatar answered Sep 28 '22 10:09

cOle2