Jump to content

Unexpected end of file


vipsa
Go to solution Solved by Barand,

Recommended Posts

I have this very simple lines of code:

<!DOCTYPE html>
<html>
<head>
<title>
Chapter 5 Strings 
</title>
</head>
<body>
    <a href="index.php">Back home</a><br><br>
    <?php
    $mytext = <<<END_TEXT
            
            This is just a bunch of text I will write here so we can test a couple of things with text.
            I will add a few lines just so we have some.
            
            END_TEXT;
      
?>
</body>
</html>

So I am getting this error  Parse error: syntax error, unexpected end of file and I would like to know why as the syntax is correct

Edited by vipsa
Link to comment
Share on other sites

  • Solution

For the benefit of those with a similar problem there should be no whitespace on the closing line of a heredoc statement ie

    <?php
    $mytext = <<<END_TEXT
            
            This is just a bunch of text I will write here so we can test a couple of things with text.
            I will add a few lines just so we have some.
            
END_TEXT;
      
    ?>

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.