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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aaronshaf
Forum Newbie
Posts: 1
Joined: Wed May 12, 2004 8:09 pm

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

Post 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?
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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;
Post Reply