php简单计数器程序(文本计数器、图形计数器)

分享二个php计数器的例子。
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"."人次";  //显示访问次数
?>
分享另外几个php计数器的例子:

1,php 文本计数器

2,php 文本计数器 实例代码

3,php计数器的简单代码 

原文地址:https://www.cnblogs.com/linuxnotes/p/3320229.html