Jump to content


Photo

Using Variables with <<<


  • Please log in to reply
4 replies to this topic

#1 jgbutler

jgbutler
  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 21 March 2006 - 09:04 PM

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:

$body=<<<_MSG_

This is the body of a message.

_MSG_;

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?

$body=<<<_MSG_

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

_MSG_;

Thanks!
Jeremy Butler[br]ScreenSite.org

#2 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 21 March 2006 - 09:21 PM

$body="<<<_MSG_This is the body of a message sent to ". $row_rsVerify['email'] ". _MSG_";


Should work for you :)

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 21 March 2006 - 09:30 PM

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.
<?php
$body=<<<_MSG_

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

_MSG_;
?>

Ken

#4 jgbutler

jgbutler
  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 March 2006 - 12:51 PM

[!--quoteo(post=357102:date=Mar 21 2006, 05:30 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 21 2006, 05:30 PM) View Post[/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]
heredoc format? 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"?!
Jeremy Butler[br]ScreenSite.org

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 March 2006 - 01:20 PM

I pronounce it here-dock myself.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users