PHP新行不会打印

时间:2012-03-21 19:41:57

标签: php email line new-operator

我一直在寻找一个小时,谷歌不是我的朋友。我已经更改了我的代码,添加了\ n \ r \ n,添加了纯文本格式,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";

我还能做些什么来打印新线?

3 个答案:

答案 0 :(得分:2)

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

尝试使用此语法,看看它是否有效。

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

答案 1 :(得分:0)

尝试使用PHP_EOL常量

用空格分隔变量和换行符:
“预计完成日期:$ formval_finish \ r \ n”;

答案 2 :(得分:0)

如果它被读作HTML,则\ n被视为空格,而不是新行。只需使用<br>代替。