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

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

  •  18-07-2023
  •  | 
  •  

Pregunta

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"

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top