我想使用邮件功能发送电子邮件。 想加换行如下。
$msg = 'aaaaa'.'\r\n'.'bbbbbb'.'\r\n';
$headers .= "Content-Type: text/plain; charset=\"utf-8\"\r\n";
$to = 'test@test.com';
mail($to,'Subject',$msg,$headers);
但不工作。
如何发送邮件如下。
啊啊啊
bbbbbb
最佳答案
新行是"\n"
,而不是'\n'
(双引号而不是单引号)。
$msg = 'aaaaa'."\n".'bbbbbb'."\n";
解释在这里:
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double
如果字符串用双引号(")括起来,PHP 会为特殊字符解释更多的转义序列
关于php - 在邮件功能php中添加换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37467724/