Re: Dots and spaces in variable names are converted to underscores.

From: Date: Wed, 20 Jan 2010 22:23:38 +0000
Subject: Re: Dots and spaces in variable names are converted to underscores.
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-46842@lists.php.net to get a copy of this message
Dots and spaces in variable names are converted to underscores. For example <input name="a.b" /> becomes $_POST["a_b"]. Any reason why? and any way to modify this behaviour to preserve dots and spaces? (dots specifically)
I'm also using dots for this reason, so I feel your pain. What I ended up doing is converting dot syntax to PHP array syntax as I compile my templates. So when I type this: <input ... name="a.b.c.d"> what I get actually compiled and sent to the browser is this: <intput ... name="a[b][c][d]"> The reason for this quirk is register_globals. The symbols not suitable for symbol names, such as dots, are replaced with underscores, so that you can access your POST variable "foo.bar" as $foo_bar in global space. Of course it never made sense the conversion is applied to the superglobals like $_COOKIE/GET/POST, but it was, and now there are claims that it'll break backwards compatibility if changed. I hope PHP6 will remove this processing as register_globals will be completely removed at that point. Regards, Stan Vassilev

Thread (22 messages)

« previous php.internals (#46842) next »