problem with variables

hi, i have a problem with this code:
[php]<?
$fromname=“prova”;
$from=“var”;

$headers = ‘From: ‘.$fromname.’ <’.$from.’>’ . “\r\n”;

//$headers = “From: $fromname <$from>\r\n”;

echo $headers;
?>[/php]

the output is just (in both cases)

From: prova 

instead of

From: prova <var>

can someone help me?thx

[php]<?
$fromname = ‘name’;
$from =“no@reply”;

$headers = 'From: '.$fromname. “\r\n”;
$headers .= 'Reply-To: '.$from. “\r\n”;

echo $headers;
?>[/php]

I think your problem is that the browser recieves your output as a tag.

“<”, “>” and others are special characters. These require special signals so the browser won’t get confused.
Try writing “<var>” instead of “”.

Another option is to do this:
[php]$headers = htmlspecialchars($headers);[/php]

The function “htmlspecialchars()” transforms special characters, like if you write “<” the browser recieves this as a regular string instead of a tag.

I hope you got it, I’m not much of an instructor :stuck_out_tongue:

Sponsor our Newsletter | Privacy Policy | Terms of Service