Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 09-12-2004, 07:56 AM   #1
Member (2 bit)
 
Join Date: Sep 2004
Location: South Cost of England
Posts: 2
Send a message via MSN to Coel
Exclamation PHP help with coding

Hello im only 14 so there are some things i dont understand.

I have spent 3 days nw working on PHP and i have become stuck, well dont know what 1 thing means.

it is the \n, what is this?

I know about the echo and using the \ to make a quotation mark. So i know about that.

It says somthing about making a new line for a character, so tell me why should i use this and what it atually means.

Thanks
Coel is offline   Reply With Quote
Old 09-12-2004, 09:46 AM   #2
Member (9 bit)
 
Join Date: May 2003
Posts: 420
Send a message via AIM to juicelooser
Yeah, all \n does is make a new line.
juicelooser is offline   Reply With Quote
Old 09-12-2004, 01:59 PM   #3
Member (7 bit)
 
shaticus's Avatar
 
Join Date: May 2004
Posts: 103
"\" is an escape character. It really tells the computer you want to put a special character or do something that should not be treated as text.
(I.E. \n creates a new line, \" prints a quote, and \\ should print a singe \"
shaticus is offline   Reply With Quote
Old 09-12-2004, 07:26 PM   #4
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
\ has the speical effect shaticus mentioned when used in double quotations.
PHP Code:
echo "Hi!\n"// output is Hi! then a new line starts
echo 'Hi!\n'// output is Hi!\n 
You may not see the new line if you are working with HTML documents, to see the new line, open the page's source.
aym is offline   Reply With Quote
Old 09-13-2004, 07:18 AM   #5
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
The main reason to use a new line is to make your HTML code more readable. Here is an example without the new line:
PHP Code:
echo "<table><tr><td><p>Content here</p></td></tr></table>";

outputs

<
table><tr><td><p>Content here</p></td></tr></table
With the new line
PHP Code:
echo "<table>\n";
echo 
"<tr>\n";
echo 
"<td><p>Content here</p></td>\n";
echo 
"</tr>\n";
echo 
"</table>\n";

outputs:

<
table>
<
tr>
<
td><p>Content here</p></td>
</
tr>
</
table
So much easier to read, validate and troubleshoot with the newline.
__________________

Want to Make $$$$ with your Computer? No Risk! Simply press shift-4 four times in a row
mairving is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:53 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2