Results 1 to 2 of 2
  1. #1
    iHolyElement's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    i can design a nation.
    Posts
    826
    Reputation
    11
    Thanks
    55

    PHP Hit counter.

    Below is a simple example of creating a visitor counter with PHP. This implementation is very small and simple but it gives you a basic structure to work off of.

    Visitor Counter

    Simply writes a counter to 'HitCounter', or to the filename of your choice.

    Code:
    class HitCounter {
      private $count;
     
      /**
       * Constructor.
       */
      public function __construct($filename = 'HitCounter') {
        $count = @file_get_contents($filename);
        $count = $count ? $count : 0;
        $fh = fopen($filename, 'w+');                
        fwrite($fh, ++$count);
        fclose($fh);
       
        $this->count = $count;   
      }
     
      /**
       * Get count.
       *    
       * @return int
       */
      public function get_count() {
        return $this->count;
      }            
     
      /**
       * Output count.
       */
      public function display_count() {
        echo 'Hits: ' . $this->get_count();
      }
    }
    Counter Usage

    Output the counter directly to the page.

    Code:
    $counter = new HitCounter();
    $counter->display_count();
    
    Custom counter message.
    $counter = new HitCounter();
    $count = $counter->get_count();
    echo 'The count is currently ' . $count;
    If you liked my tutorial please say thanks, i use a more advanced one of this but this still works, if you have some trouble with it let me know and i'll fix it. -.^

  2. #2
    PieEater289's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    58
    Reputation
    10
    Thanks
    9
    this is cool

Similar Threads

  1. Making Counter Strike Clan
    By quin123 in forum General
    Replies: 30
    Last Post: 09-01-2006, 11:37 PM
  2. Counter Strike Clan
    By quin123 in forum General Gaming
    Replies: 13
    Last Post: 08-04-2006, 04:09 PM
  3. Request: Counter-Strike CD KeyGen.
    By The_Enigma in forum Hack Requests
    Replies: 9
    Last Post: 08-01-2006, 03:30 AM
  4. Counter Strike: Source
    By Flawless in forum CounterStrike (CS) 1.6 Hacks / Counter Strike: Source (CSS) Hacks
    Replies: 15
    Last Post: 06-03-2006, 08:28 PM
  5. Lookin for WOW 1 Hit kill hack anyone know how to do it
    By Spiderman in forum General Game Hacking
    Replies: 5
    Last Post: 02-10-2006, 05:18 PM

Tags for this Thread