php的計數器程序
發表于:2007-07-14來源:作者:點擊數:
標簽:
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; exe
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="/Files/BeyondPic/2005-12/19/05121906540866084.gif"\">";
}
print "訪問量總計:"."$out_str"."人次"; //顯示訪問次數
?>
原文轉自:http://www.anti-gravitydesign.com