这是我的邮件程序的$header
代码。
我想在$em
中打印from:<>
的值,但遗憾的是它不起作用。
我不熟悉专家级的PHP,所以请妥善解决这个问题,我也想知道为什么会这样。
$em="admin@domain.com";
// 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: <admin@domain.com>
答案 0 :(得分:3)
因为<>
表示您的浏览器隐藏的HTML标记,它认为是破坏的HTML,如果您查看源代码,您将看到您的字符串。
替代地
echo htmlspecialchars($headers);