php check if request method is post code example
Example 1: php detect request type
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Boom baby we a POST method
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// We are a GET method
}
Example 2: check if post request php
Better use $_SERVER['REQUEST_METHOD']:
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// …
}
Example 3: php check request method
$_SERVER['REQUEST_METHOD']