For detecting request type in PHP we can use variable $_SERVER by using $_SERVER[‘REQUEST_METHOD’]. $_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. Following methods can be detected with key ‘REQUEST_METHOD’:

  • GET
  • POST
  • PUT


Detecting request type in PHP