Re: "\n" in PHP

From: Michael Austin (maustin_at_firstdbasource.com)
Date: 07/12/04


Date: Sun, 11 Jul 2004 22:31:30 GMT

Andy Hassall wrote:

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

unless of course you are using pre /pre tags then it will render the
data on the next line...

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

Michael Austin.