having problem with this code

i am to php, got the errorr below

Parse error: syntax error, unexpected $end in C:\wamp\www\php_sandbox\rowyourboat.php on line 34

while writing this programme and i cannot find the error despite i have search carefully

programme code below

[code]

Row Your Boat



Row Your Boat


Demonstrating Use Of Long Variables


    <?php
    
    $verse = <<<HERE
    Row, Row, Row, your boat<br />
    Gently down the stream<br />
    Merrily, merrily, merrily, merrily<br />
    Life is but a dream!<br />
    <br><br>
    HERE;
    
    print "<h3>Verse 1:</h3>";
    print $verse;
    
   
    print "<h3>Verse 2:</h3>";
    print $verse;
    
    print "<h3>Verse 3:</h3>";
    print $verse;
    
     ?>   
</body>
[/code]

Glancing at the code i believe your error is caused by the closing HERE not being at the start of the line. (IE you have a tab space before it)

Read this for a better understand of using HEREDOC syntax.
(particularly, the warning in the red/pink box)

Hope that helps,
Red :wink:

Redscouse is correct.

[php]
$verse = <<<HERE
Row, Row, Row, your boat

Gently down the stream

Merrily, merrily, merrily, merrily

Life is but a dream!




HERE;
[/php]

Heredoc statement are very picky on syntax.

Sponsor our Newsletter | Privacy Policy | Terms of Service