Well the \n isn't parsed for single quotes but it is for double quotes. Also, I'm not sure where you're trying to use it but if you are just outputting to an HTML page then it wont display the newline because whitespace characters(unless preempted with a <pre>) tag are ignored. You can use the nltobr(string) function to convert them however
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 269
Skill Endorsements: 26
Because in HTML whitespace characters (newline, space, tab) are ignored with rendering the page.
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 269
Skill Endorsements: 26
hi woobag,
i think u can use "<br>" instead of "\n"
rudevils
Junior Poster in Training
80 posts since Jan 2008
Reputation Points: 10
Solved Threads: 10
Skill Endorsements: 1
edit - I tried wrapping the PHP code in <pre> tags and that did the trick, still trying to understand why it does not work without them.
As other people have pointed out, the reason this doesn't work without a <pre> tag is that HTML ignores normal whitespace characters.
The reason it does work with a <pre> tag is that that is what <pre> tags are designed for. The text inside of a <pre> tag will be displayed with all white space intact - in your case with a newline character.
As was suggested before, use a <br /> tag instead of an '\n' if you want to create a line break in your HTML output.
However, the '\n' still has a function and it is still doing something. If you view the HTML source for the output of your script, you should notice that the newline is observed.
So, if you're echo-ing large amounts of HTML, it can be a very good idea to include newline characters in there. That way your source code is still readable and not just one long jumbled line.
- Walkere
Walkere
Junior Poster in Training
57 posts since Jan 2008
Reputation Points: 29
Solved Threads: 5
Skill Endorsements: 0
A) Don't hijack year-old threads, create your own.
B) The escape sequence is a backslash, not a forward slash (\n, NOT /n)
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 269
Skill Endorsements: 26