&&Then?> Posted June 13, 2019 Share Posted June 13, 2019 Hi, I see \n used a few times in the ch2 examples. In sorting.php for example it's used like this: echo '<tr><td colspan="2"><strong> Sorted by title:</strong></td></tr>'; foreach ($movies as $title => $rating) { // printing the list echo "<tr><td>$rating</td> <td>$title</td></tr>\n"; } However, it seems to be redundant. Doesn't the foreach loop keep printing the echo, thus creating a new line (see p.10)? In any case, if I remove the \n, there's no difference. This also applies to its use in the calendar.php example. Just wanted to check if there's some other reason for including it, because I was puzzled when I got to the "What impact does printing \n have on the browser?" question in Review and Pursue. Thanks! Link to comment Share on other sites More sharing options...
Larry Posted June 13, 2019 Share Posted June 13, 2019 The newline affects the HTML source code of the page. It's visible there, not in the visual result rendered by the browser. Link to comment Share on other sites More sharing options...
Recommended Posts