note 44955 deleted from function.fopen by aidan
| From: | aidan@php.net | Date: | Sat, 21 Aug 2004 07:20:23 +0000 |
| Subject: | note 44955 deleted from function.fopen by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75044@lists.php.net to get a copy of this message | ||
Note Submitter: anonymous
----
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);
}
?>