2012-03-21 2 views
1

약 1 시간 전에 찾고 있었지만 Google은 내 친구가 아닙니다. , PHP 새 줄이 인쇄되지 않습니다

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 

만 처음 몇 줄이 함께 인쇄 : 나는, 내 코드를 변경 n 개의 \ r을을 \ 추가, HTML 포맷 ...

이메일과 같은 인쇄하는 일반 텍스트 서식을 추가했습니다 완료 날짜 이후의 모든 것이 새로운 행에 인쇄됩니다. 여기까지 메시지의 코드는 다음과 같습니다.

//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"; 

새 줄을 인쇄하려면 어떻게해야합니까?

+1

콘텐츠 유형에 "textrn"은 무엇입니까? – allaire

+0

어떤 이메일 클라이언트에서 인쇄중인 개 라인이 보이지 않습니까? 아니면 방금 브라우저에서보고 있습니까? 전자 메일 HTML은 일반적으로 매우 까다롭기 만하지만 기본 (예 : '
')은 여전히 ​​전반적으로 작동합니다. 매번 새로운 줄에서 텍스트를 시작해야 할 때마다 한 사이트에서 본 '
' – Mattygabe

+0

을 인쇄하도록 PHP에 지시해야합니다. 누군가 평범한 텍스트 전자 메일로 변환한다고 말하면됩니다. 필자는이 코드를 한 달 동안 사용해 왔기 때문에 여전히 작동하지 않고있어 아무 것도 시도 할 필사적이되었습니다. – user1284324

답변

2

나는 이것을 전에 본 것으로 생각합니다. 임베디드 변수 바로 뒤에 \ r \ n을 사용하여 PHP에 버그가있을 수 있습니다.

이 구문을 사용해보고 제대로 작동하는지 확인하십시오.
"예상 완료일 : 연구 \ n을 \ $ formval_finish"

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

고마워, 잘 했어! – user1284324

+0

어떤 버그가 있습니까? 방법?! – meze

+0

@meze PHP 버그라고 생각하지만, 그것에 대한 보고서를 찾을 수 없었습니다. 항상 발생하는 것은 아니지만 큰 따옴표 안에 변수의 바로 뒤에 이스케이프 문자를 넣으면 이스케이프 된 문자가 항상 정확하게 파싱되지는 않습니다. 아마도 $ content. = "레스토랑 이름 : {$ formval_RestaurantName} \ r \ n"; '과 같은 것을 할 수 있습니다. – AndrewR

0

는 공간 PHP_EOL 일정
또는
별도의 변수와 줄 바꿈을 사용해보십시오;

+0

나는 이미 그것을 시도했다. – user1284324

0

HTML로 읽는 경우 \ n은 공백으로 취급되며 새 줄로 취급되지 않습니다. 대신 <br>을 사용하십시오.

관련 문제