Home > Programming > PHP WebCounter
Simple counter that increments per session. That is, the counting variable is only incremented if a new browser instance calls the page in which the counter sits.
If you copy the code, take care that there are NO SIGNS before the first "<?php" tag in the php file. The code has to be interpreted before anything is sent to the user. Also be sure that the rights of hits.txt are properly set.
|
<?php // start session // increments hit counter if user opens new session $hitfile = "hits.txt"; // if hits is not registered we register it and increment the number
in hits.txt
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <?php // function that reads hit.txt function readHit(){ ?> |
1350 people visited this page.