note 10252 deleted from function.fwrite by jimw
| From: | jimw@php.net | Date: | Fri, 19 Oct 2001 18:06:10 +0000 |
| Subject: | note 10252 deleted from function.fwrite by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19168@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;
}
}