Jump to content
Larry Ullman's Book Forums

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>

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.



Share this post

Link to post
Share on other sites

The newline affects the HTML source code of the page. It's visible there, not in the visual result rendered by the browser. 

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...