PHP – Detect HTTP Request Type

You can detect the HTTP Request Type using the following variable.



Use the following PHP to handle different HTTP Request.

  $request_method = $_SERVER['REQUEST_METHOD'];

  switch($request_method) {
    case 'PUT':
    case 'DELETE':
      // Ignore the PUT and DELETE request =P
    case 'GET':
      // GET request received
    case 'POST':
      // POST request received


Done =)

Reference: StackOverflow – PHP detecting request type (GET, POST, PUT or DELETE)

2 thoughts on “PHP – Detect HTTP Request Type”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.