php check if get request code example
Example 1: php check request method
$_SERVER['REQUEST_METHOD']
Example 2: php check method of http request
<?php
$method = $_SERVER['REQUEST_METHOD'];
switch ($method) {
case 'GET':
echo 'You are using '.$method.' Method';
break;
case 'POST':
echo 'You are using '.$method.' Method';
break;
case 'PUT':
echo 'You are using '.$method.' Method';
break;
case 'PATCH':
echo 'You are using '.$method.' Method';
break;
case 'DELETE':
echo 'You are using '.$method.' Method';
break;
case 'COPY':
echo 'You are using '.$method.' Method';
break;
case 'OPTIONS':
echo 'You are using '.$method.' Method';
break;
case 'LINK':
echo 'You are using '.$method.' Method';
break;
case 'UNLINK':
echo 'You are using '.$method.' Method';
break;
case 'PURGE':
echo 'You are using '.$method.' Method';
break;
case 'LOCK':
echo 'You are using '.$method.' Method';
break;
case 'UNLOCK':
echo 'You are using '.$method.' Method';
break;
case 'PROPFIND':
echo 'You are using '.$method.' Method';
break;
case 'VIEW':
echo 'You are using '.$method.' Method';
break;
Default:
echo 'You are using '.$method.' Method';
break;
}
?>