Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.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新行将不打印_Php_Email_Line_New Operator - Fatal编程技术网

PHP新行将不打印

PHP新行将不打印,php,email,line,new-operator,Php,Email,Line,New Operator,我已经找了一个小时了,谷歌不是我的朋友。我更改了代码,添加了\n\r,添加了纯文本格式,html格式 该电子邮件正在打印如下内容: Below is the site survey information for test Restaurant Name: test Contact Name: test Walk-Thru Contact Name: test Site Surveyor: Brandon Projected Install Date: test Projected Openin

我已经找了一个小时了,谷歌不是我的朋友。我更改了代码,添加了\n\r,添加了纯文本格式,html格式

该电子邮件正在打印如下内容:

Below is the site survey information for test Restaurant Name: test Contact Name: test Walk-Thru Contact Name: test Site Surveyor: Brandon Projected Install Date: test Projected Opening Date: test Projected Completion Date: test
Item(s) Needed: test
Priority Level: Necessary for Install
Item(s) Needed: 
Priority Level: Necessary for Install
Item(s) Needed: 
Priority Level: Necessary for Install
只有前几行一起打印,但完成日期后的所有内容都打印在新的行上。以下是迄今为止该消息的代码:

//Prepare content

$subject = "Site Survey Information";
$from_header = "From: $formval_RestaurantName";
$headers .= "Content-type: textrn";

$to = "$formval_receiver";




$contents .= "Below is the site survey information for $formval_RestaurantName\r\n";
$contents .= "Restaurant Name: $formval_RestaurantName\r\n";
$contents .= "Contact Name: $formval_ContactName\r\n"; 
$contents .= "Walk-Thru Contact Name: $formval_walkthru\r\n";
$contents .= "Site Surveyor: $formval_surveyor\r\n";
$contents .= "Projected Install Date: $formval_install\r\n";
$contents .= "Projected Opening Date: $formval_open\r\n";
$contents .= "Projected Completion Date: $formval_finish\r\n";
$contents .= "Item(s) Needed: $formval_items1\r\n";
$contents .= "Priority Level: $formval_priority_1\r\n";
$contents .= "Item(s) Needed: $formval_items2\r\n";
$contents .= "Priority Level: $formval_priority_2\r\n";
$contents .= "Item(s) Needed: $formval_items3\r\n";
$contents .= "Priority Level: $formval_priority_3\r\n";
$contents .= "Item(s) Needed: $formval_items4\r\n";
$contents .= "Priority Level: $formval_priority_4\r\n";
$contents .= "Item(s) Needed: $formval_items5\r\n";
$contents .= "Priority Level: $formval_priority_5\r\n";
$contents .= "Item(s) Needed: $formval_items6\r\n";
$contents .= "Priority Level: $formval_priority_6\r\n";
$contents .= "Item(s) Needed: $formval_items7\r\n";
$contents .= "Priority Level: $formval_priority_7\r\n";
$contents .= "Item(s) Needed: $formval_items8\r\n";
$contents .= "Priority Level: $formval_priority_8\r\n";
$contents .= "Item(s) Needed: $formval_items9\r\n";
$contents .= "Priority Level: $formval_priority_9\r\n";
$contents .= "Item(s) Needed: $formval_items10\r\n";
$contents .= "Priority Level: $formval_priority_10\r\n";
$contents .= "Item(s) Needed: $formval_items11\r\n";
$contents .= "Priority Level: $formval_priority_11\r\n";
$contents .= "Item(s) Needed: $formval_items12\r\n";
$contents .= "Priority Level: $formval_priority_12\r\n";
$contents .= "Item(s) Needed: $formval_items13\r\n";
$contents .= "Priority Level: $formval_priority_13\r\n";
$contents .= "Item(s) Needed: $formval_items14\r\n";
$contents .= "Priority Level: $formval_priority_14\r\n";
$contents .= "Item(s) Needed: $formval_items15\r\n";
$contents .= "Priority Level: $formval_priority_15\r\n";

我还能做些什么让它打印新行呢?

我想我以前见过这个。PHP中可能存在在嵌入变量之后使用\r\n的错误

试试这个语法,看看它是否有效

$contents .= 'Restaurant Name: ' . $formval_RestaurantName . "\r\n";

尝试使用PHP_EOL常量

用空格分隔变量和换行:

“预计完成日期:$formval\u finish\r\n”

如果它被读取为HTML,则\n被视为空白,而不是新行。只需使用

即可

内容类型中的“textrn”是什么?您看到哪个电子邮件客户端没有打印换行符,或者您只是在浏览器中查看?虽然电子邮件HTML一般都很挑剔,但基本的(如

)仍然可以在各方面发挥作用。每次你需要文本从一行开始,你都应该告诉PHP打印一封我在一个网站上看到的

,有人说会将其转换成纯文本电子邮件。因为我已经写了一个月的代码,但它仍然没有真正起作用,我已经绝望到可以尝试任何东西。这是outlook。只有前8项内容不打印在新行上。计划完成日期后的所有内容都将打印在新行上。该电子邮件将仅由一个人接收,并将通过outlook查看。替换
$headers.=“内容类型:文本”,提供您收到的完整原始消息,而不是outlook的复制粘贴。@meze我认为这是PHP错误,但我找不到关于它的报告。这种情况并不总是发生,但如果将转义字符放在变量后面的双引号内,则转义字符的解析并不总是正确的。您可能会执行类似于
$contents.=“餐厅名称:{$formval\u RestaurantName}\r\n”也是。