$whichwrong = "The following questions were not answered correctly: \n\n";
$whichwrong .= "Question Number: $questionNum || Your Answer: $userAnswers[$s][$q]\n";
echo $whichwrong;
顯示:在PHP不輸出換行符
The following questions were not answered correctly: Question Number: 2 || Your Answer: b Question Number: 4 || Your Answer: c Question Number: 5 || Your Answer: a Question Number: 1 || Your Answer: b Question Number: 3 || Your Answer: b Question Number: 1 || Your Answer: b Question Number: 2 || Your Answer: a Question Number: 1 || Your Answer: b Question Number: 2 || Your Answer: b
爲什麼"\n"
不能正常工作?
同時這工作得很好:
$totalValue .= "Correct: {$correct}\n";
$totalValue .= "Wrong: {$wrong}\n";
空格在瀏覽器中,查看源文件崩潰,你會看到你的換行符,使用
元素代替硬中斷; – Orangepill
使用'\ r \ n' - '\ r'是一個回車符,'\ n'是一個新行 – crmpicco