Page 1 of 1

linefeed not working

Posted: Thu Apr 03, 2008 11:07 pm
by haosmark

Code: Select all

 
    $today = Date("m/d/Y");
    $file_handle = fopen("test.txt", "w");
    fwrite($file_handle, "text written with the help of Php\n Todays date is $today");
    fclose($file_handle);
 
for some reason i can't get a linefeed to work in this code, here is what i get:
text written with the help of Php Todays date is 04/04/2008
What am i doing wrong?

Re: linefeed not working

Posted: Thu Apr 03, 2008 11:27 pm
by John Cartwright
Try

Code: Select all

   fwrite($file_handle, "text written with the help of Php\r\n Todays date is $today");

Re: linefeed not working

Posted: Thu Apr 03, 2008 11:33 pm
by haosmark
!!! It worked!
I did try to use \n at first, then \r, but that gave me the same result. What makes \r\n different?
Thanks again.

p.s. Font in between code tags is so small, very hard to read, why not increase it a bit?

Re: linefeed not working

Posted: Fri Apr 04, 2008 12:15 am
by John Cartwright
haosmark wrote:!!! It worked!
I did try to use \n at first, then \r, but that gave me the same result. What makes \r\n different?
Thanks again.
http://en.wikipedia.org/wiki/Line_feed# ... _languages