Jump to content

Heredoc question


KevinM1

Recommended Posts

Is it possible to use a function call within a heredoc if I use curly braces?  In other words, would something like the following correctly use nl2br and put the result in the output?
[code]
<?php

echo <<<EOF
<div> <!-- left side -->
<img src="$row['pic_url']" alt="" /><br />
<p>{nl2br($row['description']);}</p>
</div>

<div> <!-- right side -->
<p>$row['name']</p>
<p>$row['price']</p>
</div>
EOF;
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/29559-heredoc-question/
Share on other sites

[quote author=Crayon Violent link=topic=117462.msg479209#msg479209 date=1165344136]
you can't do that.  what you would do is make a temporary variable that calls the function like $blah = nl2br($row['description']); and then use that variable inside the heredoc.
[/quote]

Thanks for the fast reply! :)  Any chance you'd mind taking a stab at my autoload question I have a few posts down? ;)
Link to comment
https://forums.phpfreaks.com/topic/29559-heredoc-question/#findComment-135611
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.