use of '\n' in Object Oriented PHP book

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JJJJJJ
Forum Newbie
Posts: 8
Joined: Wed Jan 27, 2010 5:56 pm

use of '\n' in Object Oriented PHP book

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

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

Post by Weirdan »

\n is interpreted by php (when it occurs in string literals) as a newline.
Post Reply