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
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.
I'm having a different problem with the newline character and can find no references to it at all. I want to use the newline character for debugging purposes: to break up the source code into readable sections. I'm echoing <br> with no problems to create hard returns in my html. The problem is that when I follow my <br>s with /n's it actually prints the characters '/n' in my html!! So I'll have a hard return and then the characters /n print on the screen. I've used double quotes to parse the newline character. It still shows up on the screen. I've escaped it as //n and that doesn't work. I've used /r/n and that doesn't either. I'm still getting output and no errors, I just want /n to behave as a line break when I view the source code rather than have it appear on the screen!!
thatnks. I was having the same issues - wondering why I couldn't create a new line with \n.
I wrapped the code in <pre> tags and that did the trick. Wondering which/if you include some type of reset for <pre> within you css file? Or is this included within popular resets like Eric Meyers?
I'm having a similar problem, where it won't break the lines in the output e-mail and doesn't print the newline characters. But when I tried inserting <pre> and <br> tags, it just printed those as text in the e-mail, and didn't do anything. Help!