Fun with PHP form processing

While debugging a PHP script tonight I came across an extremely annoying PHP “feature”: it does not allow HTML input field names to contain dots and spaces.

So, if you had a HTML form with an input field “do.it” <input name="do.it" id="do.it" type="text" /> and were to process this form with PHP, PHP would report a field named “do_it”. A field named “do it” would also be converted to “do_it”. While the behavior for the second case is totally sensible and in accordance with W3C’s HTML specification (space is not allowed in name/id fields), the first is just plain annoying.

The ‘.’ character is very special in PHP, so it cannot be used for variable scoping like in VB or Java. The PHP engine will automaticly translate any ‘.’ into a ‘_’ to make it PHP-safe. Why did the ‘.’ become such a special character in PHP? Heaven knows… I hate it. Or have you ever come across a developer who thinks it’s intuitive to concatenate strings with ‘.’s? That’s just awful.

Leave a Reply