PHPBuilder - Hit Counter



RSS Twitter
Snippets Http

Hit Counter

by: Drew Bryson
|
January 11, 2003

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



<?php

// Simple counter by Sketch and kn64
// sketch@isp.net.au 

$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
?>
	

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Drew Bryson

Comment:



Comment:

(Maximum characters: 1200). You have characters left.