30. August, 2007

Fun with PHP form processing

Filed under: Web Authoring — frightanic @ 23:18

This blog now resides at It will be discontinued here…

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 “” <input name="" id="" 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.


Blog at

%d bloggers like this: