Jump to content

Archived

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

jgbutler

Using Variables with <<<

Recommended Posts

I've got a little bit of code where I fill a variable with <<< . (I'm such a newbie, I don't even know what that's called!) Like this:

[code]$body=<<<_MSG_

This is the body of a message.

_MSG_;[/code]

What I'd like to do is insert some MySQL variable information into the middle of that. I tried the following, but got a parsing error. Is there a way around this?

[code]$body=<<<_MSG_

This is the body of a message sent to $row_rsVerify['email']

_MSG_;[/code]

Thanks!

Share this post


Link to post
Share on other sites
[code]$body="<<<_MSG_This is the body of a message sent to ". $row_rsVerify['email'] ". _MSG_";[/code]


Should work for you :)

Share this post


Link to post
Share on other sites
No, that won't work. The OP is using the heredoc format. (why it's called that is lost in the antiquities of the C language... :-) ) The '<<<' is not part of the string and neither is the "_MSG_".

The solution here is to use curly brackets around the array variable.
[code]<?php
$body=<<<_MSG_

This is the body of a message sent to {$row_rsVerify['email']}

_MSG_;
?>[/code]

Ken

Share this post


Link to post
Share on other sites
[!--quoteo(post=357102:date=Mar 21 2006, 05:30 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 21 2006, 05:30 PM) [snapback]357102[/snapback][/div][div class=\'quotemain\'][!--quotec--]
No, that won't work. The OP is using the heredoc format. (why it's called that is lost in the antiquities of the C language... :-) ) The '<<<' is not part of the string and neither is the "_MSG_".

The solution here is to use curly brackets around the array variable.
[/quote]
[b]heredoc format[/b]? Man, I never would've guess that! Or the curly braces!

But that's just what I needed.

When you don't know the name for something, it makes it mighty hard to search for help with it.

Thanks a heap!

P.S. How is "heredoc" pronounced? Is it like "heretic" or "hear-dock"?!

Share this post


Link to post
Share on other sites

×

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.