Coder Profile - Show off your skills, get a coder profile.
 
 
 
code pin board Page Hit Counter Class Download Source Code
Author Details Code Information
VBAssassin ( Scott Thompson )

Pinned 8 Codes
Posted 13 Coding Articles

Send A Message
View Coders Profile
Language PHP (Hypertext Preprocessor)
Expires Never
Length 551 Characters (24 Lines)
Password no password
Description

in response to: http://www.coderprofile.com/source-code/328/simple-hit-counter

not tested this code.
  1. <?php
  2. class hitCount {
  3.           private $file = '';
  4.           function __construct($file) {
  5.                     $this->file = $file;
  6.           }
  7.           function getCount() {
  8.                     return intval(@file_get_contents($this->file));
  9.           }
  10.           function addCount($count = 1) {
  11.                     file_put_contents($this->file, intval(@file_get_contents($this->file)) + $count);
  12.           }
  13.           function removeCount($count = 1) {
  14.                     file_put_contents($this->file, intval(@file_get_contents($this->file)) - $count);
  15.           }
  16. }
  17. ?>
  18.  
  19.  
  20. <?php
  21.           $counter = new hitCount('count.txt');
  22.           $counter->addCount();
  23.           print $counter->getCount();
  24.   ?>
code pin board Back To Code Pin Board Post New Code
Please login to post comments.
 
Relish     Posted 205 Days Ago
 
 
I fixed up my counter.

haha, we did almost the same thing, using @file_get_contents, etc...

http://www.coderprofile.com/source-code/328/simple-hit-counter-v12
 
Relish     Posted 206 Days Ago
 
 
I am modifying that one to be better and more efficient. Thanks though :D
Page 1 of 1
 
 
Part of the MyPingle Network
Development Blog :: Make A Donation :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents
Version 1.44.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved