Create a count.dat file in the same directory
Add this code to your php file
You can uncoment the echo if you want to display the count to the vistors.
I have created another file that opens the count.dat file and shows me the amount of visitors so only I can see it. Basically it's the same code, but with the line $counter++ comented out
<?php
$counter_file= "count.dat";
if(!($fp = fopen($counter_file, "r+"))) die ("Can not open file");
$counter = (int) fread($fp,20);
$counter++;
//echo "you're visitor number $counter";
rewind($fp);
fwrite($fp,$counter);
fclose($fp);
?>
Doing it this way, you are only opening the file one time, usingin the rewind function.