Jump to content
Larry Ullman's Book Forums

Question about \n in Chapter 2


Recommended Posts

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

 Share

×
×
  • Create New...