johnsm
asked on
\n does not bring me to a new line
If I have the following code, it all gets printed on the same line.
print "hello\n";
print "next line";
output looks like this:
hellonext line
Why would that be?
I have build 316 of the code. This is the latest version I've seen. Is there something I'm doing wrong?
Thanks.
print "hello\n";
print "next line";
output looks like this:
hellonext line
Why would that be?
I have build 316 of the code. This is the latest version I've seen. Is there something I'm doing wrong?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You don't really have to do it, but you would like to do it. Because when writing scripts you sometimes want to read the source code in your browser (view source). If you don't do the \n, then the whole result is on one line and very hard to read.
alternative solution: you can output
print "hello\r\n";
print "next line";
print "hello\r\n";
print "next line";
ASKER
I had originally tried adding the <br>, but it was always outside of the quotes and simply produced a <br> (literally) on my page. I didn't think of puting it inside the quotes.
Now this brings up another point. I don't really need the \n if the <br> is what is being used to do a new line.
Hmmm. Interesting.