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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.