PHP Parse error: syntax error, unexpected T_SL

chris (2010-02-09 07:56:17)
2452 views
0 replies
This is a hard one to spot, so I thought it would be worth posting up here in the hope that it will save somebody some time. The PHP error looks like this:

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
   <div>here is some html</div>
EOT;

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


christo
comment