Lowell Jehu Lowell Jehu - 1 month ago 9
MySQL Question

( ! ) Parse error: syntax error, unexpected '<<' (T_SL) on line 6


( ! ) Parse error: syntax error, unexpected '<<' (T_SL) on line 6


the error is from line 6 where display block is i have removed the spaces from it and even closed it. the code still wont run then when i removed the ; the whole code goes yellow.
i have another code that has the same error to and tried removing the(<<) but nothing closed it still the same thing. the only time it reads past this is when i remove the ;. but the whole code after that line turns yellow

<?php
include 'ch19_include.php';
if (!$_POST) {
//haven't seen the form, so display it
$display_block = <<<END_OF_BLOCK;
<form method="POST" action="$_SERVER[PHP_SELF]">;

<p><label for="subject">Subject:</label><br/>
<input type="text" id="subject" name="subject" size="40" /></p>

<p><label for="message">Mail Body:</label><br/>
<textarea id="message" name="message" cols="50" rows="10"> </textarea></p>
<button type="submit" name="submit" value="submit">Submit</button>
</form>
END_OF_BLOCK;

Answer
$display_block = <<<END_OF_BLOCK
(your text)
END_OF_BLOCK;

remove the semicolon after the first END_OF_BLOCK. the "code turning yellow" is just your editor telling you it knows this piece of code is a heredoc-string. nothing to worry about.

Comments