"\n" in PHP

From: Mudge (mark1822_at_hotmail.com)
Date: 07/11/04


Date: Sun, 11 Jul 2004 17:48:44 GMT

I am reading a book called "PHP, Apache, MySQL Web Development"
http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764557440.html

and in its example code it sometimes will have a "\n" in it. It is driving
me crazy because php will ignore the "\n"s so i have no idea why this book
has them in there. Does anybody know?

For example:

if (mysql_num_rows($result))
{
        echo "<div class=\"scroller\">\n";
        while ($row = mysql_fetch_array($result))
        {
                echo "<span class='commentname'>".
                htmlspecialchars($row['name']).
                "</span><span class='commentdate'>
                (". date("1 F j, Y H:i", strtotime($row['comment_date'])).
                ")</span>\n";
                        
                echo "<p class='commenttext'>\n".
                nl2br(htmlspecialchars($row['comment'])).
                "\n</p>\n";
        }
        echo "</div>\n";
}
echo "<br />\n";

Why does the book put the "\n"s in there?



Relevant Pages

  • Re: [PHP] Good PHP book?
    ... although I learnt largely with 'PHP, Apache, MySQL Web Development' from ... WROX. ...
    (php.general)
  • A mystery: Why were my settings not working?
    ... I was having problems getting mysql to work with php on my apache ... Thankfully I got it working after reading a different thread, ... Latest mysql with the latest Connector\PHP files in the proper PHP ... Apache Environment ...
    (comp.lang.php)
  • Re: <%variable%> in html template ??
    ... Therefore I am sure it is now Apache not reading tags as PHP. ...
    (comp.lang.php)
  • Re: <%variable%> in html template ??
    ... Therefore I am sure it is now Apache not reading tags as PHP. ...
    (comp.lang.php)
  • Help with this code?
    ... This is straight out of a book I'm reading to learn PHP. ... maybe I set either apache or PHP up incorrectly on my computer. ...
    (comp.lang.php)