Gautam Jha
Gautam Jha

Reputation: 1473

php variable in string not appering

This is my mailer's $header code.

I wanted to print the value of $em in from:<> but sadly it is not working.

i don't know PHP at expert level so kindly fix this problem, also I would like to know why this is happening.

$em="[email protected]";
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:  <$em>" . "\r\n";
echo $headers;

Current Output:


MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: 

Expected Output:

MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: <[email protected]>

Upvotes: 1

Views: 46

Answers (1)

user557846
user557846

Reputation:

as <> denotes a HTML tag your browser is hiding what it thinks is the broken HTML, if you view source you will see your string.

alternatively

echo htmlspecialchars($headers);

Upvotes: 3

Related Questions