If I am issuing an HTTP DELETE, how can I access the PHP body/variable? I know if you\'re issuing POST, you access it via $_POST[\'varname\']
, but how do you access
file_get_contents('php://input') should always give you the complete request body. Note that it may be readable only once. The bigger question is whether a DELETE request may contain a body, which seems to be something of an unanswered question, but will probably work.
I'd say sending the id in the body is somewhat RESTless though. The entity in question should be referred to by the URL as example.com/foo/42
, so a DELETE request should say DELETE /foo/42
, not DELETE /foo
with the id in the request body.