Jump to content


Deleting Text in a File

  • Please log in to reply
2 replies to this topic

#1 GRPsuper

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 15 April 2006 - 04:13 PM

what is the code i would need if i wanted to delete all text in a php file with a chmod set to 7,7,7,7?

#2 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 April 2006 - 09:50 PM

Use fopen to open the file then fwrite that'll erase al data in the file.

#3 ypirc

  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 16 April 2006 - 03:24 AM

Follow what wildteen stated, but make sure your fopen mode is set to either "w" or "w+". Alternatively, you can also use file_put_contents if you are using PHP 5+ or you could also use unlink which will remove the file and then you can recreate it at your will. As you can see there are several possibilities. I suggest checking out www.php.net/filesystem

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users