Page 2 of 2

Posted: Tue Jul 19, 2005 3:48 pm
by IceMetalPunk
If you are only using "w" in the begining so you can create it if it doesn't exist (unless I'm missing something), I'd do something like this in the begining instead:

Code: Select all

if (!file_exists("myfile.ext")) {
fclose(fopen("myfile.ext","w"));
}
That will create a blank file if it doesn't exist, but will not clear the file if it already exists.

-IMP ;) :)

Posted: Tue Jul 19, 2005 3:50 pm
by Chris Corbyn
IceMetalPunk wrote:If you are only using "w" in the begining so you can create it if it doesn't exist (unless I'm missing something), I'd do something like this in the begining instead:

Code: Select all

if (!file_exists("myfile.ext")) {
fclose(fopen("myfile.ext","w"));
}
That will create a blank file if it doesn't exist, but will not clear the file if it already exists.

-IMP ;) :)
You're right but unfortunately he/she needs to read the data from $fp too ;)

Posted: Tue Jul 19, 2005 3:58 pm
by Chris Corbyn
You may also want to look into ftruncate($fp, 0) as a method of clearing the file ;)