Re: Dots and spaces in variable names are converted to underscores.
| From: | Rasmus Lerdorf | Date: | Wed, 20 Jan 2010 22:29:27 +0000 |
| Subject: | Re: Dots and spaces in variable names are converted to underscores. | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-46843@lists.php.net to get a copy of this message | ||
Stan Vassilev wrote:
-RasmusDots 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. Well, that conversion still needs to happen somewhere, since plenty of apps call extract() on those superglobals, but with register_globals entirely gone in PHP 6, I suppose that conversion can be moved to the extract() call.