Page 1 of 1

I need a special way to feed html into a string variable

Posted: Wed May 12, 2004 8:09 pm
by aaronshaf
I'm in a situation where I need to feed html text into a string variable, in a way like this:

<?

$var = "

?>

text text text

<? ";

echo someFunction( $var );

?>

Obviously, that isn't working. Any suggestions?

Posted: Wed May 12, 2004 9:05 pm
by launchcode
Easiest way is probably the heredoc syntax:

Code: Select all

$var = <<<EOD
Here is some HTML 
including <img src="pic.gif"> images and <b>all sorts</b>
EOD;

echo $var;