首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP新行将不打印

问PHP新行将不打印
EN

Stack Overflow用户
提问于 2012-03-22 03:41:57
回答 3查看 525关注 0票数 1

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

该电子邮件的打印方式如下:

代码语言:javascript
复制
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

只有前几行打印在一起,但完成日期之后的所有内容都打印在新行上。到目前为止,消息的代码如下:

代码语言:javascript
复制
//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";

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

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-03-22 03:51:20

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

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

代码语言:javascript
复制
$contents .= 'Restaurant Name: ' . $formval_RestaurantName . "\r\n";
票数 2
EN

Stack Overflow用户

发布于 2012-03-22 03:55:27

尝试使用PHP_EOL常量

或

用空格分隔变量和换行符:

“预计完成日期:$formval_finish \r\n";

票数 0
EN

Stack Overflow用户

发布于 2015-03-22 06:19:38

如果它被读取为HTML,则\n将被视为空格,而不是换行符。只需使用<br>即可。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9811699

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档