php
2016-07-05 89 views 1 likes 
1

這是我的郵件程序的$header代碼。php變量不包含字符串

我想在from:<>中打印$em的值,但遺憾的是它不起作用。

我不知道在專家級別的PHP,所以很好解決這個問題,我也想知道爲什麼會發生這種情況。

$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; 

電流輸出:


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

預期輸出:

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

回答

3

<>表示您的瀏覽器隱藏它認爲是破損的HTML的HTML標記,如果您查看源代碼,您將看到您的字符串。

或者

echo htmlspecialchars($headers); 
+0

'$標誌=電子郵件($到,$主題,$消息,$頭);'可以請你看在這個代碼我的郵箱不能正常工作 –

相關問題