Новая строка PHP НЕ будет печатать - PullRequest
1 голос
/ 21 марта 2012

Я искал около часа, Google не мой друг.Я изменил свой код, добавил \ 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";

Что еще я могу сделать, чтобы заставить его печатать новые строки?

Ответы [ 3 ]

2 голосов
/ 21 марта 2012

Я думаю, что видел это раньше. В PHP может быть ошибка с использованием \ r \ n сразу после встроенной переменной.

Попробуйте этот синтаксис и посмотрите, работает ли он.

$contents .= 'Restaurant Name: ' . $formval_RestaurantName . "\r\n";
0 голосов
/ 22 марта 2015

Если он читается как HTML, то \ n рассматривается как пробел, а не как новая строка. Просто используйте <br> вместо этого.

0 голосов
/ 21 марта 2012

попробуйте использовать константу PHP_EOLили жеотдельная переменная и символ новой строки с пробелом:«Предполагаемая дата завершения: $ formval_finish \ r \ n»;

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...