$fileName="counter.dat";
$fileHandle=fopen($fileName, 'r') or die("can't open file");
$count = 0;
if(!feof($fileHandle))
{
$input = fgets($fileHandle, 4096);
$count = intval($input);
$count++;
}
fclose($fileHandle);
if ($count != 0)
{
$fileHandle = fopen($fileName, 'w') or die ("can't open file");
fwrite($fileHandle, $count);
fclose($fileHandle);
}
echo('Visitors: '.$count);
Of course you can have a much nicer way of displaying the number of visitors but for the moment, only the basic idea is relevant.
No comments:
Post a Comment