note 14886 added to function.fopen.php

From: Date: Mon, 20 Aug 2001 00:56:47 +0000
Subject: note 14886 added to function.fopen.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-16899@lists.php.net to get a copy of this message
If you need to replace the contents of a file, but are getting problems with ownership/permissions, ftruncate can be used to effectively delete the contents by truncating the size of the file to 0 thus; ftruncate($file,0); fwrite($file,$my_stuff); Using this method will allow you to replace the file contents without changing ownership. The alternative method of using unlink() to delete the file then replacing it with a new file is unsatisfactory because the file created will be owned by 'nobody'. http://www.php.net/manual/en/function.fopen.php

« previous php.notes (#16899) next »