php http request code example
Example 1: php http 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;
}
?>
Example 3: get http method php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
Example 4: what does $request do in php
$message = "";
if($_REQUEST['msg'] == "new"){
$message = "New User has been added successfully";
}else if($_REQUEST['msg'] == 'edit'){
$message = "User has been saved successfully";
}else if($_REQUEST['msg'] == 'update'){
$message = "User(s) has been Updated successfully";
}