Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 24, 2012, 11:43:52 AM

Pages: [1]   Go Down
  Print  
Author Topic: escape sequences  (Read 318 times)
Johnny
MR-Disabled
Über Jedi
*
Offline Offline

Posts: 1914



« on: November 22, 2002, 12:29:00 PM »

I'm learning PHP. The book that I'm using touches on escape sequences, but it doesn't mention what they do.

Here's a few that I'm interested in knowing about, as I see these quite often in scripts:

\n linefeed.... Is that the same as <br>?
\r carriage return ..... I have no clue
\horizontal tab ..... No clue

If someone could tell me what these do, I sure would appreciate it.
Thanks
Logged

charle97
Galactic Royalty
*****
Offline Offline

Posts: 420


WWW
« Reply #1 on: November 22, 2002, 12:34:00 PM »

i don't know php myself but this might help:

 http://perl.about.com/library/phpCR/bl_escape_sequences.htm
Logged

Rowan
hamburglar
Über Jedi
*****
Offline Offline

Posts: 1919


I used to be Human....2.0b


WWW
« Reply #2 on: November 22, 2002, 03:17:00 PM »

\n is a new  line  just like <br>
\horizontal tab is the same as pressing the tab key
\r i always forget but its similar to \n
Logged

JamesYap
Intergalactic Superstar
*****
Offline Offline

Posts: 167



WWW
« Reply #3 on: November 28, 2002, 03:35:00 PM »

Finally I can voice myself in this forum. hehe.

/n means new line character it is different with <br>, because <br> is an HTML tag while /n is a computer character.

in php if you
echo "Lunar <br> Pages";
Your browser will display it as

Lunar
Pages

BUT for
echo "Lunar\n Pages";
your browser display

Lunar Pages

!!! becuase HTML ignore white spaces characters(space, new line characters, tabs ...). To see what the \n actually did, you can select view -> source in IE to see the source code, for the 1st example using <br> you get source code

Lunar <br> Pages

for the 2nd example using \n you will see

Lunar
Pages

Get the point? In HTML even 1,000,000 white space characters are treaten as one single space. So \n are use to format your source code nicely so that you can debug/check your PHP output easily. (Else all your code is joint in a single line!)

So as \t. \t it is tab character. You will see the TAB in your source code but it will not be display the TAB.

for \r is return character and \v is vertical chacacter, explanation for this 2 will be lenghtly (Is is back to the DOS world where \r means return to the left side of the screen, \v means move to next line but below). Ignore them as they are very confusing. You don't need to use them in PHP scriping.
Logged

Why LunarPages is the best web hosting? Read our LunarPages Review to find out now.
Pages: [1]   Go Up
  Print  
 
Jump to: