How can I detect which request type was used (GET, POST, PUT or DELETE) in PHP?
You can use getenv function and don't have to work with a $_SERVER variable:
getenv
$_SERVER
getenv('REQUEST_METHOD');
More info:
http://php.net/manual/en/function.getenv.php