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
As stated by people above, PHP does not have a global variable to quickly access data in a DELETE
request. Why, I do not know; it probably hasn't been as used as GET
and POST
historically.
You would have to check the request type using $_SERVER['REQUEST_METHOD']
and then retrieve the entire body using the php://input
stream and extract your data from that. You could create a function that does this on every request and saves it in a global variable named $_DELETE
if you would like to keep a similar look to your code (assuming you use $_POST
and $_GET
). You could even patch your PHP to do this and compiling your own version of PHP, but that would of course confuse people who try to run your code on another PHP installation :)