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?
I need a special way to feed html into a string variable
Moderator: General Moderators
- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact:
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;