php的计数器程序_php基础

WBOY
Release: 2016-05-17 09:49:08
Original
1330 people have browsed it

1)文本计数器
$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$each_num = substr($num,$i,1);
$out_str = $out_str . "php的计数器程序_php基础";
}
print "访问量总计:"."$out_str"."人次";  //显示访问次数
?>


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template