Jump to content

[SOLVED] PHP MAIL - EMBEDDED VARIABLE CALL


paradrenaline

Recommended Posts

I am using PHPMailer and I have having a problem getting a variable($name) to display in my HTML version of the message.  The variable is embedded within the code for another variable $Body.

 

$Body ='

<html>

<head>

<title></title>

</head>

<body>

<p>Dear $name,</p>

........more code

';

 

My question is this: how do  I make a call to a variable within a variable?  Do I need to use double quotes instead of single here as shown in this example?

 

// HTML body

    $body  = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";

 

 

Any help would be great, I am just not certain how to call the variable and was unable to find an example.

 

Thanks for your time to help!

 

Link to comment
https://forums.phpfreaks.com/topic/37922-solved-php-mail-embedded-variable-call/
Share on other sites

1) Just for learning, we don't usually say you "call" variables because you are not making them do anything which you do with functions.

2) What you do is finish the string, insert the variable and then start the string again.

For instance:

$myString = "The name of my site is" . $sitename . " and etc";

 

Here is an example with single quotes and multiple variables:

$myString2 = 'I am ' . $name .' and I am ' . $feeling . ' to meet you';

Hi,

 

php variables within single quotes will act as a constant.

please try with doubtle quotes.

 

can you pls clarify me whether you are trying to parse a html mail to take the fill name

                                     or

you having a standard template for the mail and you are trying to replace the name in that template.

 

Regards,

I am indeed trying to replace the name in the template.

 

Thanks for the help and the learning about "calling" functions not variables!

 

ShogunWarrior your suggestion worked perfect.  I appreciate the help greatly.

 

take care

 

 

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.