GET/POST whitespace stripping behavior

php.internals

Christopher Kunz

21 years ago
Hi, I have a general question in regard to the PHP variable normalizing. Obviously, leading whitespace in a variable is stripped, but why is trailing whitespace converted to underscores? Example: /?foo=bar&+fooo=blah&foooooo+=ljalskdf results in: array(3) { ["foo"]=> string(3) "bar" ["fooo"]=> string(4) "blah" ["foooooo_"]=> string(8) "ljalskdf" } I can understand why one would want to convert middle spaces (like in "foo+bar") to underscores, but shouldn't trailing spaces be stripped instead? Am I missing something? Regards, --ck

Pawel Bernat

21 years ago
On Mon, Aug 08, 2005 at 03:37:53PM +0200, Christopher Kunz wrote:
> Hi, > > I have a general question in regard to the PHP variable normalizing. Obviously, > leading whitespace in a variable is stripped, but why is trailing whitespace > converted to underscores?
See http://php.net/manual/en/function.urldecode.php
-- Paweł Bernat; uselessness' lover; select'<asm'||chr(64)||'asm'||'.'||'flynet'||chr(46)||'pl>'as email; Slowly and surely the unix crept up on the Nintendo user ...

Derick Rethans

21 years ago
On Mon, 8 Aug 2005, Pawel Bernat wrote:
> On Mon, Aug 08, 2005 at 03:37:53PM +0200, Christopher Kunz wrote: > > Hi, > > > > I have a general question in regard to the PHP variable normalizing. Obviously, > > leading whitespace in a variable is stripped, but why is trailing whitespace > > converted to underscores? > See http://php.net/manual/en/function.urldecode.php
He's asking 'why' not 'how'... Derick
-- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org

Christopher Kunz

21 years ago
> He's asking 'why' not 'how'... >
Right. My suspicion is that this is from the old days, when men were men and GET variables were not in $_GET - but the inconsistency kinda bugs me. There has to be someone who remembers why they wrote it that way...? Anyone? Rasmus? :) --ck