FTW Web Designs Free Hit Counter (PHP)

This is our free PHP hit counter created by our in-house PHP specialist.

Here is the code & some basic info on how it works.

You also need a "hits.txt" file with a 0 in it to start with, or whatever number you wish your hits to start on.
Place the hits.txt and counter.php in the same directory.

Heres an example;
"Hits : 58"

Then in your home page or any pages you wish to include the counter on place the following code where you want the counter to be;

<?php include('counter.php'); ?>

Code for counter.php

 

 <?php
#############
#HIT COUNTER#
###################
#BY FTW WEB DESIGN#
######################
#www.ftwwebdesign.com#
######################

// Now 1st we need to get the number from the hits.txt
$currentHits = file_get_contents('hits.txt');
//Now we add 1 to the current number of hits.
$currentHits = $currentHits + 1;
//We open the file for writing only "w" mode.
$writeToHits = fopen("hits.txt", "w");
//We write to the file the new hits number
fwrite($writeToHits, $currentHits);
//Close the file.
fclose($writeToHits);
//And finally echo the current hits
echo "Hits : " . $currentHits;
?>

Here are all the files to download Below this message.

Become a user of FTW WEB DESIGN to recieve info every week on;

  1. Web design & Graphic Deals.
  2. New Web Designer Tips & Resources.
  3. New Services & Site Updates.
  4. - There will be no more than 1 email per week. We wont spam you or give your email to anyone else.

Download FTW Web Designs Free Hit Counter (PHP)