Re: New globals for PUT and DELETE
| From: | Ben Ramsey | Date: | Tue, 14 Oct 2014 13:09:41 +0000 |
| Subject: | Re: New globals for PUT and DELETE | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77977@lists.php.net to get a copy of this message | ||
On Oct 14, 2014, at 7:47 AM, Kris Craig <kris.craig@gmail.com> wrote:
> Hey guys,
>
> Does anybody know why we have $_GET and $_POST, but not $_PUT and
> $_DELETE? As far as I can tell, the only way to get these out currently is
> to parse their values by reading the incoming stream directly.
>
> Is there a reason why we don't want this or is it just that nobody has
> actually written it yet?
>
> —Kris
This is due to the history of HTML forms sending POST requests with the Content-Type
application/x-www-form-urlencoded. That is, all the fields are key/value pairs and may be easily
converted into a PHP array. If you use POST with application/json, nothing appears in $_POST, for
example.
In practice, we could support $_PUT and $_DELETE for requests that use
application/x-www-form-urlencoded, but most folks implementing PUT and DELETE do not use
application/x-www-form-urlencoded for these requests.
I would venture to say that most people implementing PUT requests accept application/json and most
DELETE requests have no body at all. So, $_PUT and $_DELETE superglobals wouldn’t make sense.
-Ben