By using
$_SERVER['REQUEST_METHOD']
Example
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// The request is using the POST method
}
For more details please see the documentation for the $_SERVER variable.
More Related Contents:
- How do I send a POST request with PHP?
- Doing HTTP requests FROM Laravel to an external API
- Asynchronous HTTP requests in PHP
- How do I implement basic “Long Polling”?
- PHP, cURL, and HTTP POST example?
- How to make asynchronous HTTP requests in PHP
- Can PHP cURL retrieve response headers AND body in a single request?
- Forcing to download a file using PHP
- How to send a GET request from PHP?
- Simultaneous Requests to PHP Script
- Easy way to test a URL for 404 in PHP?
- Get raw post data
- Utility of HTTP header “Content-Type: application/force-download” for mobile?
- Persistent/keepalive HTTP with the PHP Curl library?
- Send post request using Volley and receive in PHP
- Setup HTTP expires headers using PHP and Apache
- How to get the previous url using PHP
- How to make PHP generate Chunked response
- Request headers bag is missing Authorization header in Symfony 2?
- PHP multipart form data PUT request?
- Add http:// prefix to URL when missing
- GET vs. POST Best Practices
- Download Multiple files in one HTTP request
- Show Curl POST Request Headers? Is there a way to do this?
- Simple comet example using php and jquery
- NginX issues HTTP 499 error after 60 seconds despite config. (PHP and AWS)
- Parsing HTTP_RANGE header in PHP
- Allowing users to Refresh browser without the “Confirm Form Resubmission” pop-up
- Unit Test Laravel’s FormRequest
- PHP, pass array through POST