php的计数器程序

1)文本计数器

 1   
 2$countfile="/count.txt"; //设置保存数据的文件   
 3if (!file_exists($countfile)){//判断文件是否存在   
 4exec( "echo 0 > $countfile");   
 5}   
 6$fp = fopen($countfile,"rw");   
 7$length=filesize($countfile);   
 8$num = fgets($fp,$length);   
 9$num += 1;   
10exec( "rm -rf $countfile");   
11exec( "echo $num > $countfile");   
12print "访问量总计:"."$num"."人次"; //显示访问次数   

2)图形计数器

$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 . " ``` ``` "; } print "访问量总计:"."$out_str"."人次"; //显示访问次数 ?>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus