Re: Can you make a file empty?

From: Date: Tue, 20 Feb 2001 23:03:04 +0000
Subject: Re: Can you make a file empty?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40845@lists.php.net to get a copy of this message
> I am trying to delete all text in a file. > $yourfile = "file.txt"; > $fp = fopen($yourfile,w) > "is there any good code to put in here?" > fclose($fp); You should check that $fp is valid. if (!$fp){ echo "Unable to empty $yourfile<BR>\n"; } But pretty much, the fopen($yourfile, 'w') is going to make the file be empty. NOTE: If you are doing this for security reasons, that doesn't mean that a *real* hacker can't have some sort of tool to dig into random bytes of the hard drive and see what used to be in the file... But any user that has that much access to your web server probably has more interesting things to do to mess you up... Still, there may be better ways to wipe the data itself out if it's particularly sensitive. -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#40845) next »