Re: "\n" in PHP

From: Andy Hassall (andy_at_andyh.co.uk)
Date: 07/11/04


Date: Sun, 11 Jul 2004 19:09:57 +0100

On Sun, 11 Jul 2004 17:48:44 GMT, Mudge <mark1822@hotmail.com> wrote:

>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?

 What makes you think PHP will ignore the "\n"s? It does not.

>For example:
>
>if (mysql_num_rows($result))
>{
> echo "<div class=\"scroller\">\n";
>
>Why does the book put the "\n"s in there?

 To make the produced HTML source easier to read, most likely.

 Although if they were concerned about readability they'd consider using single
quotes instead of doubles, and avoiding all those backslashes.

 Maybe you're thinking of the fact that newlines aren't significant in HTML,
i.e. it won't force a new line in the rendered output. Nothing to do with PHP,
though.

--
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk         / http://www.andyhsoftware.co.uk/space


Relevant Pages

  • Re: " " in PHP
    ... Andy Hassall wrote: ... > To make the produced HTML source easier to read, ... > Maybe you're thinking of the fact that newlines aren't significant in HTML, ... > i.e. it won't force a new line in the rendered output. ...
    (comp.lang.php)
  • Re: PHP has encountered an Access Violation at 00B973CD
    ... trying to write / update a file (or access database) on the webserver from ... "Andy Hassall" wrote in message ... >>PHP has encountered an Access Violation at 00B973CD ... >>OS: Windows XP Pro SP1 ...
    (comp.lang.php)
  • Re: A possible bug in php .3.10 ?
    ... Andy Hassall wrote: ...
    (comp.lang.php)
  • Re: Can I learn PHP 5 with PHP 4 book?
    ... Jerry Stuckle wrote: ... Andy Hassall wrote: ... The minimum PHP version required for mysqli is 5.0. ...
    (comp.lang.php)
  • Re: Source code Bug or Feature?
    ... > Andy Hassall wrote: ... > And use long opening tags: <?php ... > or you'll get in trouble with different configs or xml docs. ...
    (comp.lang.php)