I needed a very simple counter and made this code. Is there any optimizations to be made?
<?php
$file = fopen ("snok.dat", "r+");
$count = fread ($file, 8);
$count = $count + 1;
ftruncate ($file, 0);
rewind ($file);
fwrite ($file, $count);
fclose ($file);
echo $count;
?>