三款php计数器代码,无需数据库,文本文件保存网页浏览计数。
1、php计数器代码:
2、php计数器
<?php
$counterfile = "balong.txt";//存储数值的文件名几路径
function displaycounter($counterfile) {
$fp = fopen($counterfile,"rw");
$num = fgets($fp,5);
$num += 1;
print "您是第 "."$num"." 个看巴泷计数器的家伙";
exec( "rm -rf $counterfile");
exec( "echo $num > $counterfile");
}
if (!file_exists($counterfile)) {
exec( "echo 0 > $counterfile");
}
displaycounter($counterfile);
?>
3、php计数器代码
<?php
$counterfile = "www.plcxue.com.txt";//存储数值的文件名几路径
function displaycounter($counterfile) {
$fp = fopen($counterfile,"rw");
$num = fgets($fp,5);
$num += 1;
print "您是第 "."$num"." 个看巴泷计数器的家伙";
exec( "rm -rf $counterfile");
exec( "echo $num > $counterfile");
}
if (!file_exists($counterfile)) {
exec( "echo 0 > $counterfile");
}
displaycounter($counterfile);
?>