0
$whichwrong = "The following questions were not answered correctly: \n\n";
$whichwrong .= "Question Number: $questionNum || Your Answer: $userAnswers[$s][$q]\n";
echo $whichwrong;

表示:

次の質問は正しく答えられませんでした: 質問番号: 2 || あなたの答え: b 質問番号: 4 || あなたの答え: c 質問番号: 5 || あなたの答え: 質問番号: 1 || あなたの答え: b 質問番号: 3 || あなたの答え: b 質問番号: 1 || あなたの答え: b 質問番号: 2 || あなたの答え: 質問番号: 1 || あなたの答え: b 質問番号: 2 || あなたの答え: b

"\n"が正しく機能しないのはなぜですか?

一方、これはうまくいきます:

$totalValue .= "Correct: {$correct}\n";
$totalValue .= "Wrong: {$wrong}\n";
4

2 に答える 2

2

nl2brhtml-改行の挿入に使用( <br />)

echo nl2br($whichwrong);

通常\nは、ブラウザによって通常の空白のように扱われます。

于 2013-06-18T15:42:09.690 に答える
2

ブラウザで表示している場合は、 を使用する必要があります<br>- 機能も使用できnl2br()ます。コンソールにいる場合は、試してください\r\n

于 2013-06-18T15:42:24.490 に答える