Once upon a time, a long time ago, PHP imported all GET/POST/COOKIE
data as variables, for the convenience of the developer.

This was called "register_globals"

$a.b is not a valid variable name, so it was changed to $a_b to be a
valid variable name.

Nowadays, I see no real reason to keep doing this, other than BC.

And I'm not sure who would actually use 'a.b' and then expect 'a_b',
but I have to assume somebody has done that, perhaps consuming an API
from somewhere else.

Short-term, your options are to use $_SERVER['REQUEST_URI'] and parse
it yourself, or "don't do that".

Long-term, I suggest you lobby for this to change in PHP 6, if it
isn't already in the works.

For BC, I suppose PHP could have *both* 'a.b' and 'a_b', or yet
another php.ini flag (sorry!) to choose the behaviour.

On Wed, January 20, 2010 3:45 pm, Nathan Rixham wrote:
> 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)
>
> reason, when building "linked data" / rdf based applications using PHP
> it's most beneficial to use subject / predicate URIs (eg
> http://xmlns.com/foaf/0.1/mbox) as form input names.
>
> also worth noting that if you send:
>   <input name="a.b[c.d]" />
> you'll receive the following in php:
>   $_POST[a_b] => array('c.d' => val)
> note no conversion of c.d to c_d
>
> regards,
>
> Nathan
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to