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

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

  •  18-07-2023
  •  | 
  •  

문제

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"

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top