Jump to content

Unexpected end of file


vipsa

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

Link to comment
https://forums.phpfreaks.com/topic/285574-unexpected-end-of-file/
Share on other sites

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;
      
    ?>

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.