Jump to content

Parser says this line is wrong T_SL error ?


larka06

Recommended Posts

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.

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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.