Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向文本/普通电子邮件添加换行符(\r\n\r\n)_Php - Fatal编程技术网

Php 向文本/普通电子邮件添加换行符(\r\n\r\n)

Php 向文本/普通电子邮件添加换行符(\r\n\r\n),php,Php,只是遇到了一个奇怪的愚蠢问题-换行符\r\n不适用于文本/纯文本 (通过PHP发送)。找到临时解决方案,即: . PHP_EOL; 但我想了解您的问题所在\r\n 我以纯文本的形式接收它们。当前代码: $note = ucwords($name).' has just sent you the file:\r\n\r\n'; 因此,收到的电子邮件如下所示:用户刚刚向您发送了文件:\r\n\r\n 有什么不对劲的提示吗?使用nl2brlike $note = ucwords($name).'

只是遇到了一个奇怪的愚蠢问题-换行符\r\n不适用于文本/纯文本 (通过PHP发送)。找到临时解决方案,即:

. PHP_EOL;
但我想了解您的问题所在\r\n 我以纯文本的形式接收它们。当前代码:

$note = ucwords($name).' has just sent you the file:\r\n\r\n';
因此,收到的电子邮件如下所示:用户刚刚向您发送了文件:\r\n\r\n
有什么不对劲的提示吗?

使用
nl2br
like

$note = ucwords($name).' has just sent you the file:\r\n\r\n';
$note = nl2br($note);

单引号不能解释特殊字符。您必须改用双引号:

此代码不起作用:

$note = ucwords($name).' has just sent you the file:\r\n\r\n';
此代码适用于:

$note = ucwords($name)." has just sent you the file:\r\n\r\n";

使用双引号$注意=ucwords($name)。“刚刚向您发送了文件:\r\n\r\n”;以我的名义!伙计,哈哈。。。该死的……)这总是一个故事——奇怪的虫子总是很容易解释的。谢谢。它起作用了。。。该死的双引号!谢谢