php heredoc syntax GOTCHA


If you are using the heredoc syntax in php

echo <<< EOT formatted spaceEOT;


and you find yourself getting the following error:
parse error: syntax error, unexpected $end in (document.php) on line #
then chances are you have added a space or tab AFTER the last EOT;
I knew it was important to have no spaces and such BEFORE it on the same line, but turns out you can’t have spaces afterwards either! So watch out.


Leave a Reply

Your email address will not be published. Required fields are marked *