1)文本計數器
<?php
$countfile="/count.txt"; //設置保存數據的文件
if (!file_exists($countfile)){//判斷文件是否存在
exec( "echo 0 > $countfile");
}
$fp = fopen($countfile,"rw");
$length=filesize($countfile);
$num = fgets($fp,$length);
$num += 1;
exec( "rm -rf $countfile");
exec( "echo $num > $countfile");
print "訪問量總計:"."$num"."人次"; //顯示訪問次數
?>
2)圖形計數器
<?
$countfile="/count-num.txt"; //設置保存數據的文件
if (!file_exists($countfile)) //判斷文件是否存在
{exec( "echo 0 > $countfile");}
$fp = fopen($countfile,"rw");
$length=filesize($countfile);
$num = fgets($fp,$length);
$num += 1;
exec( "rm -rf $countfile");
exec( "echo $num > $countfile");
$len_str = strlen($num);
for($i=0;$i<$len_str;$i++){
$each_num = substr($num,$i,1);
$out_str = $out_str . "<img src=\"$each_num.gif\">";
}
print "訪問量總計:"."$out_str"."人次"; //顯示訪問次數
?>