This gets the number from a page (i.e. 56) and then adds one to it and saves the page.
When run again it does the same. (You may need to create the hitcounter.txt and add the number 0 to start it?)
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php $count_my_page = ("hitcounter.txt"); $hits = file($count_my_page); $hits[0] ++; $fp = fopen($count_my_page , "w"); fputs($fp , "$hits[0]"); fclose($fp); $hitme = $hits[0]; echo $hitme; ?> |