How to determine the type of HTTP request (GET, POST, PUT, DELETE) in PHP?
Hi everyone! I'm a beginner in PHP and writing a simple REST API for a study project. I have one script `api.php` that should handle different request types: GET — retrieving data, POST — creating a new record, PUT — updating, DELETE — deleting.
But I don't understand how exactly to find out which method the client used in PHP. I've seen someone using `$_SERVER['REQUEST_METHOD']`, but I'm not sure if that's correct. Also, I tried sending PUT and DELETE via Postman, but in my code they are somehow detected as GET. Here's my example:
```php
No answers yet.
Log in to leave an answer