“Comment vérifier la méthode de demande en php” Réponses codées

Type de demande de détection PHP

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
     // Boom baby we a POST method
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
     // We are a GET method
}
Grepper

Méthode de vérification PHP de la demande HTTP

<?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;
}


?>
Gifted Goat

Comment vérifier la méthode de demande en php

// Check request method in php using super global variable $_SERVER
if(isset($_SERVER['REQUEST_METHOD'])){
	// Now display request method
    echo $_SERVER['REQUEST_METHOD'];
}
Abhay Mishra

Réponses similaires à “Comment vérifier la méthode de demande en php”

Questions similaires à “Comment vérifier la méthode de demande en php”

Plus de réponses similaires à “Comment vérifier la méthode de demande en php” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code