linefeed not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
haosmark
Forum Newbie
Posts: 10
Joined: Wed Mar 19, 2008 12:10 pm

linefeed not working

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: linefeed not working

Post by John Cartwright »

Try

Code: Select all

   fwrite($file_handle, "text written with the help of Php\r\n Todays date is $today");
haosmark
Forum Newbie
Posts: 10
Joined: Wed Mar 19, 2008 12:10 pm

Re: linefeed not working

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: linefeed not working

Post 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
Post Reply