larka06 Posted August 25, 2013 Share Posted August 25, 2013 I have this error but can not see what is wrong. The parser says: PHP Parse error: syntax error, unexpected T_SL in sort_words_by_length.php on line 40. What is T_SL? below is the line it objects to followed by the whole text. <?php Line 40 -- $myText = <<<END_TEXT But think not that this famous town has only harpooners, cannibals, and bumpkins to show her visitors. Not at all. Still New Bedford is a queer place. Had it not been for us whalemen, that tract of land would this day perhaps have been in as howling condition as the coast of Labrador. END_TEXT; I have reread on heredocs and can not find anything wrong. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted August 25, 2013 Share Posted August 25, 2013 the unexpected t_sl is referring to a shift left operator <<. somehow the <<< is being seen as unexpected. post about 5 lines leading up to what you posted above, there's probably something missing, like a quote or a ; Quote Link to comment Share on other sites More sharing options...
Solution jcbones Posted August 25, 2013 Solution Share Posted August 25, 2013 (edited) The heredoc syntax requires <<<END_TEXT to be the end of the opening line: Edit: since there are no variables that need interpolating, you could change this line to a nowdoc (by putting single quotes around the opening 'END_TEXT'). $myText = <<<END_TEXT But think not that this famous town has only harpooners, cannibals, and bumpkins to show her visitors. Not at all. Still New Bedford is a queer place. Had it not been for us whalemen, that tract of land would this day perhaps have been in as howling condition as the coast of Labrador. END_TEXT; Edited August 25, 2013 by jcbones Quote Link to comment Share on other sites More sharing options...
larka06 Posted August 26, 2013 Author Share Posted August 26, 2013 Thank both of you. There is nothing above it but the opening <?php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.