Re: New globals for PUT and DELETE

From: Date: Tue, 14 Oct 2014 21:51:41 +0000
Subject: Re: New globals for PUT and DELETE
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.internals 
Request: Send a blank email to internals+get-78074@lists.php.net to get a copy of this message
On 14/10/2014 22:43, Rowan Collins wrote:
On 14/10/2014 21:21, Rasmus Lerdorf wrote:
On 10/14/2014 11:16 AM, Rowan Collins wrote:
On 14/10/2014 17:18, Rasmus Lerdorf wrote:
I think 20+ years of history has proven this to be a non-issue. Of all the things that people get confused by in PHP, $_GET/$_POST are right near the bottom of the list.
The popularity of REST is what has changed this. Until people started writing RESTful APIs, only two HTTP request types were in common use. Nobody was confused about where PUT method data would end up, because nobody processed any PUT methods.
It makes no sense to me to make $_BODY an alias for $_POST. $_POST implies the default body encoding that a broswer performs on a POST request. Making an alias called $_BODY that doesn't contain the body of a request unless it is "POST"-encoded would be super confusing.
The encoding has no relationship with the request type, even in browsers - the default encoding of a POST form is actually the same encoding used to produce a URL form a GET form.
Sure, but $_GET/$_POST do. They were not named to match HTTP primitives. They were named to match form methods. As in form method="get" and method="post". And here the default encoding the browsers use for these two methods definitely matter.
Like, I say, application/x-www-form-urlencoded is the default encoding for both method="get" and method="post". The difference is that one executes an HTTP GET, and appends the encoded data to the request URL, while the other executes an HTTP POST, and encloses the encoded data as the request body. Even coming from a browser form, both $_GET and $_POST can be populated simultaneously, with independent data: <form method="post" action="/test.php?foo=query+data"><input type="hidden" name="foo" value="body data" /></form>
Actually, I think I misunderstood your post (insert bad pun here about "I didn't get it") and should probably go to bed. I think this thread is probably just repeating itself now anyway. -- Rowan Collins [IMSoP]

« previous php.internals (#78074) next »