Sign In | Sign Up

My Profile

kyliechan
32320
.....
Points: 64
Gender: Female
Constellation: Aquarius

Shortcuts

Categories

Post

Basic Hit Counter In PHP
Size: Large, Medium, Small Sat Jul 4, 09 12:01 PM | Category: Sharing
1

Original Articles: http://cheng-jk.hostei.com/blog/2009/06/basic-hit-counter-in-php

 

A very basic hit counter in PHP; it uses a text file to store the number of hits and displays the number of current hits.

if (gethostbyaddr($_SERVER['REMOTE_ADDR']))  
{  
  $CntFile = "HitCounter.txt";  
  $Hits = file($CntFile);  
  $CurrHits = $Hits[0]++;
  
  $FileHandle= fopen($CntFile, "w"); // Open as a writable file
  fputs($FileHandle, $CurrHits);  
  fclose($FileHandle);  
  echo "Hits: ".number_format($CurrHits);  
}

Original Articles: http://cheng-jk.hostei.com/blog/2009/06/basic-hit-counter-in-php


Link: http://blog.bitcomet.com/kyliechan/post_101686/ ©
Add to favorites | Quote Reads (294) | Comments (1)
Next: 爱情观

Related Posts

CommentsReload

koyotee39 Sat Jul 4, 09 03:23 PM

HI GOOD POST VOTED



TOP