note 44955 added to function.fopen

From: Date: Sat, 21 Aug 2004 02:02:30 +0000
Subject: note 44955 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-75037@lists.php.net to get a copy of this message
if you have multiple file operations on one file after and after you need to use 'clearstatcache'! else it will read the informations from cache and those will be wrong. example (writing new content at the beginning of the file): <?php for ($i = 0; $i < 100; $i++) { clearstatcache(); // clearing all file stat caches $fp = fopen($fname, "r"); $c = fread($fp, filesize($fname)); $fclose($fp); $c = "new content" . $c; $fp = fopen($fname, "w"); fwrite($fp, $c, strlen($c)); fclose($fp); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.fopen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44955 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44955&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44955&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75037) next »