function display_hits() {
$data_file = "number.txt";
# File that stores the count
# The file should be world writable
# i.e., chmod 777 number.txt
$done = FALSE;
$fp = fopen ($data_file,"r+");
while ($done == FALSE)
if (flock ($fp, 2) == TRUE) {
#lock file
$hitcount = fread ($fp, filesize ($data_file));
$hitcount = (int) $hitcount;
$hitcount ++;
fseek($fp, - filesize ($data_file), SEEK_CUR);
fwrite ($fp, $hitcount);
flock($fp, 3); #release lock
fclose ($fp);
$done = TRUE;
}
echo ("$hitcount hits.");
}
___________________