Version: 1.0

Type: Full Script

Category: HTTP

License: GNU General Public License

Description: Basic hit counter we made as a little project to learn about PHP. 2 Files


// Simple counter by Sketch and kn64

$filename = "hit.log"; // sets File path as variable

$fp = fopen($filename, 'r'); // opens file with read permissions

$hits = fgets($fp); // reads file to 4096bytes

fclose($fp); // closes file

$hits++; // increments variable

$fp = fopen($filename, 'w'); // opens file for writing

fputs($fp, $hits); // adds $hits

fclose($fp); // closes file once more

echo ("<p>$hits people have entered this site!</p>"); // Displays it on website