Php Check Method Of Http Request

[Solved] Php Check Method Of Http Request | Php - Code Explorer | yomemimo.com
Question : php check method of http request

Answered by : gifted-goat-71zoj95ihq2l

<?php
$method = $_SERVER['REQUEST_METHOD'];
switch ($method) { case 'GET': //Here Handle GET Request echo 'You are using '.$method.' Method'; break; case 'POST': //Here Handle POST Request echo 'You are using '.$method.' Method'; break; case 'PUT': //Here Handle PUT Request echo 'You are using '.$method.' Method'; break; case 'PATCH': //Here Handle PATCH Request echo 'You are using '.$method.' Method'; break; case 'DELETE': //Here Handle DELETE Request echo 'You are using '.$method.' Method'; break; case 'COPY': //Here Handle COPY Request echo 'You are using '.$method.' Method'; break; case 'OPTIONS': //Here Handle OPTIONS Request echo 'You are using '.$method.' Method'; break; case 'LINK': //Here Handle LINK Request echo 'You are using '.$method.' Method'; break; case 'UNLINK': //Here Handle UNLINK Request echo 'You are using '.$method.' Method'; break; case 'PURGE': //Here Handle PURGE Request echo 'You are using '.$method.' Method'; break; case 'LOCK': //Here Handle LOCK Request echo 'You are using '.$method.' Method'; break; case 'UNLOCK': //Here Handle UNLOCK Request echo 'You are using '.$method.' Method'; break; case 'PROPFIND': //Here Handle PROPFIND Request echo 'You are using '.$method.' Method'; break; case 'VIEW': //Here Handle VIEW Request echo 'You are using '.$method.' Method'; break; Default: echo 'You are using '.$method.' Method'; break;
}
?>

Source : https://stackoverflow.com/questions/359047/detecting-request-type-in-php-get-post-put-or-delete?rq=1 | Last Update : Fri, 25 Sep 20

Answers related to php check method of http request

Code Explorer Popular Question For Php