Closed Thread Icon

Topic awaiting preservation: fwrite() error Pages that link to <a href="https://ozoneasylum.com/backlink?for=12018" title="Pages that link to Topic awaiting preservation: fwrite() error" rel="nofollow" >Topic awaiting preservation: fwrite() error\

 
Author Thread
butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 01-25-2002 00:36

I have written code that is to delete everything in a text file. I tried using:

fwrite(" ", $fp);

but that left a line with " " in the file which caused an unwanted item to appear on the page that file provides content for.

I ended up using:

fwrite("", $fp);

but that poped an error, I assume because I'm not really giving it anything to write to the file. This code did what I wanted it to, so I added the @ to silence the error and moved on.

Now I'm wondering if there may be some consequenses to this that I don't know about. If there is, what method should I use to delete *everything* from a text file?

Thanks

-Butcher-

Weadah
Maniac (V) Mad Scientist

From: TipToToe
Insane since: Aug 2000

posted posted 01-25-2002 01:04

Hey, not sure if it's correct weight but :

$killFile = fopen('whatever.txt','w+');
fclose($killFile);

Results a blank file (pointer at zero).
Someone else will know more. Could be unlink() you want ?

Weadz

[This message has been edited by Weadah (edited 01-25-2002).]

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 01-25-2002 12:04

the 'w+' will open file for writing and append to the file, use instead:

$killFile = fopen('whatever.txt','w');
fclose($killFile);

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 01-25-2002 12:33

Thanks guys

-Butcher-

« BackwardsOnwards »

Show Forum Drop Down Menu