1

Possible Duplicate:
HEREDOC interfering with code indentation

<?php
        $my_string = <<<TO
         Everything in this rather unnecessarily wordy
        ramble of prose will be incorporated into the 
        string that we are building up inevitably, 
        inexorably, character by character, line by line, 
        until we reach that blessed //final line which is this one.
        TO;
        echo $my_string;
    ?>

it's error is:

Parse error: syntax error, unexpected $end in C:\wamp\www\ITP - Teaching\PHP\Chapter VIII - String\Heredoc Syntax\index.php on line 19
Community
  • 1
  • 1

2 Answers2

6

The closing TO must not be indented.

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
2

Heredoc end needs to be at the start of a row, try this:

<?php
        $my_string = <<<TO
         Everything in this rather unnecessarily wordy
        ramble of prose will be incorporated into the 
        string that we are building up inevitably, 
        inexorably, character by character, line by line, 
        until we reach that blessed //final line which is this one.
TO;
        echo $my_string;
    ?>
cypher
  • 6,822
  • 4
  • 31
  • 48