Forum Moderators: coopster

Message Too Old, No Replies

write new line, is windows different

         

topr8

4:45 pm on Oct 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



have a php script and am trying to write text (javascript actually) to a page and am trying to output it on different lines to send to the browser.

i've done this:

echo "some text \n" ;
echo "some text \n" ;
echo "some text \n" ;

which i thought would be written as seperate lines, however that is not the case, is this because i'm testing on a windows box or am i missing the point?

barns101

6:13 pm on Oct 26, 2006 (gmt 0)

10+ Year Member



Try this:


echo "some text \r\n";

Psychopsia

6:14 pm on Oct 26, 2006 (gmt 0)

10+ Year Member



Hi!

Check this link: [webmasterworld.com...]

topr8

8:11 pm on Oct 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thanks barns101 thant did the trick, needed the \r as well

good call Psychopsia, although i was actually trying to write the source code on seperate/new lines, i'm dynamically writing some javascript and i want it on seperate lines of code ... am not trying to format line breaks as seen by a browser.

eelixduppy

3:08 am on Oct 27, 2006 (gmt 0)



This is very interesting, actually. Your original example should have worked, even on a Windows machine. I'm still investigating this, but as long as the carriage return works for you then I guess you're good.

By the way, does it still not work when you omit the linefeed (\n) and just keep the carriage return (\r), or do you need both to work on your machine? It's just that I find this odd and would like to know all the details, if you don't mind ;)

topr8

10:10 am on Oct 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hmm, i'm glad you said that eelixduppy, because i thought it should work, i'm pretty sure i'd done it before like that...

i'm always into investigation, i'll run the different variations of the code and report it here for you.