Jump to content

Using Variables with <<<


jgbutler

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!
Link to comment
https://forums.phpfreaks.com/topic/5443-using-variables-with/
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
Link to comment
https://forums.phpfreaks.com/topic/5443-using-variables-with/#findComment-19471
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"?!
Link to comment
https://forums.phpfreaks.com/topic/5443-using-variables-with/#findComment-19631
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.