Friday, January 28, 2011

PHP Parse error: syntax error, unexpected T_SL in

SkyHi @ Friday, January 28, 2011
PHP Parse error:  syntax error, unexpected T_SL in 


One of the things that I regularly whinge at my team in Yahoo! about is meaningful log messages. It really doesn't make sense to log an error if it isn't clear what is being communicated, or what possible course of action an engineer/developer might take to resolve the problem.

PHP commonly slips up on this point. There are even cases of errors being logged in Hebrew! In order for an error message to be useful, it should be a) Tagged in some way so that monitoring systems can be hooked into it, and b) it should bear some meaningful information for whoever is likely to read the message.

In this case, the fix is simple. The message is probably complaining about a trailing whitespace on the end of a HEREDOC declaration. For exmaple, if your heredoc looks like this:

$html = <<<EOT
here is some html

Then you should check after the first 'EOT' to see if there is some whitespace immediately after it.