If you want to make your counter looked more beautiful, you can use image file to arrange it. This article will explain how to make beautiful counter with image. You need to prepare any file image that contain number 0.jpg until 9.jpg. Then you make a file named data.txt and put any number in data.txt. Don't forget to put data.txt in same place of counter.php. For image file like 0.jpg until 9.jpg, put them in folder './picture/'.
Next, create php file named counter.php and paste code below..
<?php
//counter.php
//check and read file data.txt
if(file_exists("data.txt"))
{
$PF=fopen("data.txt",'r');
$num=fgets($PF,4096);
fclose($PF);
//add value to $num
$num++;
$PF=fopen("data.txt",'w');
fputs($PF,$num);
fclose($PF);
chop($num);
$nb_digits=max(strlen($num),6);
$num=substr("0000000000".$num,-$nb_digits);
//show on page
$num=preg_split("//",$num);
echo "Number of visitors are";
//counter.php
//check and read file data.txt
if(file_exists("data.txt"))
{
$PF=fopen("data.txt",'r');
$num=fgets($PF,4096);
fclose($PF);
//add value to $num
$num++;
$PF=fopen("data.txt",'w');
fputs($PF,$num);
fclose($PF);
chop($num);
$nb_digits=max(strlen($num),6);
$num=substr("0000000000".$num,-$nb_digits);
//show on page
$num=preg_split("//",$num);
echo "Number of visitors are";
for ($i=0; $i<=$nb_digits;$i++)
{
if($num[$i]!="")
{
echo "<IMG SRC=\"./picture/$num[$i].jpg\">";
}
}
}else
{
echo "file data.txt no found.";
}
?>