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

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

  •  18-07-2023
  •  | 
  •  

Domanda

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"

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top