Jump to content

Parser says this line is wrong T_SL error ?


larka06
Go to solution Solved by jcbones,

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.

Link to comment
Share on other sites

  • Solution

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 by jcbones
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.