Detecting request type in PHP

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
  • DELETE

Example:

Nishant Vaity

I am a skilled self-taught PHP developer with years of experience writing scalable code for high-traffic websites. I am proficient in Linux, Apache, MySQL, PHP, HTML, JavaScript, CSS, Git, SVN, Vagrant, and SSH, among others. I am contributor for WordPress open source plugins and Translator (Marathi) for WordPress 4.5.x. I am passionate about the technologies I use and am always eager to share that passion and learn more.

Leave a Reply

Your email address will not be published. Required fields are marked *