PHP eval and heredoc don't play nicely

eval, heredoc, php

Solution

HEREDOC syntax is ended by the delimiter defined at the start, followed by a semicolon, followed by a newline. You do not have the newline, therefore it is not being recognised as the end of the HEREDOC. Add an extra `\n` after `TEMPLATE;` and it should work fine.

Problem

Possible Duplicate: heredoc with eval code execution So I have the following in function.php: ``` eval("\$content = <<<TEMPLATE\n asdf \nTEMPLATE;"); ``` And I keep getting an error saying: ``` Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_END_HEREDOC or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in /var/www/function.php(10) : eval()'d code on line 5 ``` I cannot figure out what the problem is. There is obviously an ending for the heredoc syntax, does heredoc just not like to play nice with eval?

Original source