fwrite() question

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
remyx187
Forum Newbie
Posts: 8
Joined: Tue Apr 29, 2008 11:49 am

fwrite() question

Post by remyx187 »

Hi,
I have a minor problem

I write to an empty txt file some data, but when I try to write again to that same file, the previously inputted data disappears and gets replaced with the new data. I was wondering why that is and if there is an "append" function that i can use other than fwrite(). Maybe im just doing something wrong and dont realize it.

thanks in advance.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: fwrite() question

Post by flying_circus »

When you issue the fopen() method, look at the mode argument

http://us.php.net/manual/en/function.fopen.php

fopen('myfile','a'); // Appends the file
fopen('myfile','w'); // Overwrites the file
remyx187
Forum Newbie
Posts: 8
Joined: Tue Apr 29, 2008 11:49 am

Re: fwrite() question

Post by remyx187 »

hey thanks, worked great, i knew it was simple
Post Reply