Link to home
Start Free TrialLog in
Avatar of johnsm
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.
ASKER CERTIFIED SOLUTION
Avatar of sybe
sybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnsm
johnsm

ASKER

That worked.

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.
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";