简体   繁体   中英

PHP-Heredoc: Not working?

Whats wrong with my PHP and why is heredoc not working. Im getting an error message.

    <!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
    </head>
    <body>

        <?php
          $text = <<< EOT
          Line 1\n
          Line2\n
          Line3.
          EOT;

          echo $text;
        ?>


    </body>
</html>

try to place your ending heredoc at the beginning of line. if you are using an IDE that have indentation, remove them! your ending heredoc should be vertically in the same line as your ending php tag(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM