note 10252 added to fwrite
| From: | mindotron at hotmail dot com | Date: | Wed, 20 Dec 2000 23:42:16 +0000 |
| Subject: | note 10252 added to fwrite | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8982@lists.php.net to get a copy of this message | ||
/*simple counter script - the function return value is the new value of the counter, so you stick it
in whereever you need it.*/
function counter_init($file_name) {
if(!file_exists($file_name)) {
$fp = fopen($file_name, 'w');
fwrite($fp, '1');
fclose($fp);
return '1';
}
else {
$fp = fopen($file_name, 'r');
$buffer = fread($fp, 26);
fclose($fp);
$buffer = (integer)$buffer +1;
$fp = fopen($file_name, 'w');
fwrite($fp, $buffer);
fclose($fp);
return $buffer;
}
}
http://www.php.net/manual/function.fwrite.php