PHP: get the request method

This snippet can be used to get the request method:

switch ($_SERVER['REQUEST_METHOD']) {
  case 'GET': $params = empty($_GET) ? null : $_GET;
  break;
  case 'POST': $params = empty($_POST) ? null : $_POST;
  break;
}

Leave a Reply