Heredoc inside eval?

From: Date: Sat, 14 Feb 2009 13:58:16 +0000
Subject: Heredoc inside eval?
Groups: php.general 
Request: Send a blank email to php-general+get-288258@lists.php.net to get a copy of this message
I have a html template with php variables. I then run it through eval(). All that works fine. Problem is that when I add simple html attributes or javascript calls I need to use single or double quotes. And this is where eval throws an error. So I then used htmlspecialchars to mask all the non-php code and then decode after eval. Then I remembered the heredoc syntax which allows both single and double quotes. So I wrote this line: eval("\$html=<<<hds\n\r$html;\n\rhds;"); But eval keeps giving me a parse error: Parse error: syntax error, unexpected $end in index.php(33) : eval()'d code on line 13 I have tried using \r\n instead which returns error at line 11. If I wrap the variable in {} as it should results in line 11 also. If I insert a space after the 'hds' I get a T_SL error. I have tried to make a wrapper heredoc variable for $html but that didn't have any effect. I am running out of ideas...

« previous php.general (#288258) next »