|
A simple hit counter using a file
-
<?php
-
/*
-
Name: Brkwtzandrew
-
Site: http://brkwtzandrew.nfshost.com
-
Script: Counter Script
-
Description: A simple hit counter that uses a file to record the number of visitors.
-
Last-edited: 1 January 2006
-
Important: You need to create a file called hits.txt in the same directory where the script runs
-
*/
-
$file = "hits.txt";
-
// The file to open (you have to create it)
-
$handle = fopen($file, "r");
-
// open the file
-
-
// assigns the content of the file to the number of hits
-
-
++$hits;
-
//add a hit for the current user
-
$handle2 = fopen($file, "w+");
-
-
// Add the current visit to the hits.
-
-
echo "You have ". "$hits". " visits";
-
// Output number of hits.
-
?>
|