Thursday, March 8, 2007

Interface Gripe #3 - PHP Error Messages

I'm learning PHP right now for work, and it's not the most fun thing in the world after using Ruby On Rails. C'est la vie.

However, error messages like this don't help much:

Parse error: syntax error, unexpected T_SL in /usr/local/apache2/htdocs/proj/include/file.php on line 703


That's supposed to tell me that there's probably an extra space after my declaration of a tag for a heredoc:


$foo = <<<END_FOO[ space ]


The T_SL stands for the Token Shift-Left operator. At least it's not too hard to search for these messages.

I know that it's possible that this error could arise due to a condition unrelated to heredocs. However, I'm a big advocate of providing extra support for the common case. If you want to take this to an extreme, you can do a study on the various causes of an error that might produce a given message. Then you provide extra context or help text for the most common case(s). I know there's a (DWIM, QWAN, TMTOWTDI, DRY)-style acronym out there somewhere for this principle, but it escapes me at the moment.

No comments: