File based page counter : Page Counter : Components PHP Source Code


PHP Source Code » Components » Page Counter »

 

File based page counter



<!-- Create an empty file myData.dat first -->       
       
       
<?php
$cfile = "myData.dat";
$fh = fopen($cfile, "r+");

if (!$fh){
    die("<BR>Failed to open file <I>$cfile</I>.");
}
$s = fgets($fh, 6);

$count = (int$s;
$count = $count + 1;
$count = str_pad($count, 6);

rewind($fh);
fwrite($fh, $count);

echo "$count";

fclose($fh);
?>



           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Components
» Page Counter