What's the difference between `Request::isMethod('post')` and `Input::server("REQUEST_METHOD") == "POST"`

StackOverflow https://stackoverflow.com/questions/23556172

  •  18-07-2023
  •  | 
  •  

Question

I'd like to know the difference between these two way for detect the post request method, thanks.

  1. Request::isMethod('post')

  2. Input::server("REQUEST_METHOD") == "POST"

Was it helpful?

Solution

Request::isMethod is basically doing what your second example is doing but internally. It's a method on Symfony\Component\HttpFoundation\Request which simply gets the request method and compares it to the method you provide as the first parameter.

So the only difference is that you have to write more for the second one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top