2012-03-21 6 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 

のみ最初の数行が一緒に印刷されています。私は、電子メールのような印刷されています...書式設定プレーンテキスト、HTMLフォーマットを追加し、\ n個の\ rを追加、

を自分のコードを変更しました完了日後のすべてが新しい行に印刷されます。これまでのメッセージのコードは次のとおりです。

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

Content-typeには「textrn」とは何ですか? – allaire

+0

どの電子メールクライアントに改行が印刷されていないのを見ていますか、それとも単にブラウザで表示していますか?電子メールのHTMLは一般的にそれほど精巧ではありませんが、基本的なもの( '
'など)はまだ全面的に機能しています。新しい行でテキストを開始する必要があるたびに、PHPに「
」 – Mattygabe

+0

を1つのサイトで印刷して、誰かがプレーンテキストの電子メールに変換すると言ってください。私はこのコードを1ヶ月間作業していて、それはまだ実際には機能していないので、何かを試してみるには絶望的になりました。 – user1284324

答えて

2

私は以前これを見たと思います。埋め込み変数の直後に\ r \ nを使用してPHPにバグがある可能性があります。

この構文を試して、動作するかどうかを確認してください。

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

ありがとう、素晴らしい仕事! – user1284324

+0

どのようなバグですか?どうやって?! – meze

+0

@meze PHPバグだと思いますが、レポートを見つけることができませんでした。必ずしも起こるとは限りませんが、二重引用符で囲まれた変数の直後にエスケープ文字を置くと、エスケープされた文字が常に正しく解析されるとは限りません。 '$ contents。="レストラン名:{$ formval_RestaurantName} \ r \ n ";"のようなこともできます。 – AndrewR

0

スペースとPHP_EOL定数
または
別の変数と改行使用してみてください:
"写し出された完了日:$ formval_finish \ rをする\ n";

+0

私はすでにそれを試みました。 – user1284324

0

HTMLとして読み込まれている場合、\ nは改行ではなく空白として扱われます。代わりに<br>を使用してください。