Page 1 of 1

use of '\n' in Object Oriented PHP book

Posted: Fri May 07, 2010 6:48 am
by JJJJJJ
Hi there,

I have been going through a book called Object Oriented PHP by Peter Lavin.

I've notice a couple of places so far where he is putting together strings of HTML code and he uses '\n' at the end. Such as:

Code: Select all

$this->spanNextInactive = "<span class=\"" .
		    "$this->inactiveSpanName\">$this->navNext</span>\n";
I've also seen him use '\n' after a

Code: Select all

<br />
tag.

I don't understand why he does this. There is no '\n' is normal HTML code, so why put one in here? The code works fine without it, but I'd really like to know if I'm missing something important.

Many thanks in advance

Joe

Re: use of '\n' in Object Oriented PHP book

Posted: Fri May 07, 2010 8:30 am
by Weirdan
\n is interpreted by php (when it occurs in string literals) as a newline.