How do I store the contents of this php echo into a variable?

fuzzybabybunny

Moderator<br>Digital & Video Cameras
Moderator
Jan 2, 2006
10,455
35
91
I want to store the contents of this echo into one big variable called $emailText. Not too sure how to do it.

Code:
echo 
'VLP Photography Job: <a href="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q='.$_POST["address"].'" target=_blank>'.$_POST["address"].'</a>
<br/><br/><b>Type of Job:</b><br/><br/>'
.
'<a href="'
.
$joblink
.
'" target="_blank">'
.
$_POST["typejob"]
.
'</a>'
.
'<br/><br/><b>Address:</b><br/><br/>'
.
$_POST["address"]
.
'<br/><br/><b>Time:</b><br/><br/>'
.
$_POST["time"]
.
'<br/><br/><b>Client:</b><br/><br/>'
.
$_POST["realtor"]
.
'<br/><br/><b>Photographer Notes:</b><br/><br/>'
.
$formattednotes
.
'<br/><br /><b>Thank you!</b>
<br />-Victor
<br />victor@victorlinphoto.com
<br />http://www.victorlinphoto.com
<br />650.248.0289'
 

Cogman

Lifer
Sep 19, 2000
10,286
147
106
From the console? It would be something like php myphpapp.php > outputfile.txt
 

fuzzybabybunny

Moderator<br>Digital & Video Cameras
Moderator
Jan 2, 2006
10,455
35
91
From the console? It would be something like php myphpapp.php > outputfile.txt

No, in the code itself.

Basically, I coded it originally to echo all that stuff. Now I don't want it to echo it, but instead store it all as a variable.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,708
4,669
75
Think about what you've done here. You've created an echo command that takes...what? A string. A very long string, but just one string nonetheless.

So assign that string to a variable instead.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
$my_echo = 'x'
. 'y'
. 'z' ;

If the PHP interpreter gets tired after 30 or 40 lines, you can always let it start over with the adding and concatenating and appending by using '.=' instead of just '=':

$my_echo .= 'x2'
. 'y2'
...
. 'z42' ;
 
Last edited:

fuzzybabybunny

Moderator<br>Digital & Video Cameras
Moderator
Jan 2, 2006
10,455
35
91
I figured it out. All I needed to do was replace echo with $messagetext= and make sure there was a ; at the end.

What was screwing me up was that I was trying to add " around the whole thing, like if I were to do:

$messagetext = "Message text.";

Adding quotes messed things up.