$cFile="count.txt";
$acctime=time();
if(file_exists($cFile)){
$fp=fopen($cFile,"r");
$str=fgets($fp,22);
fclose($fp);
$count=trim($str);
$count++;
}else{
$count=1;
}
$first=false;
if(!isset($_COOKIE['acctime'])){
setcookie("acctime",$acctime,time()+3600*24);
$first=true;
$acctime=3600*24+$acctime;
}else{
$acctime=3600*24+$_COOKIE['acctime'];
}
if($first||$acctime<=time()){
$count=sprintf("%d",$count);
$fp=fopen($cFile,"w");
fputs($fp,$count);
fclose($fp);
}else{
$count--;
}
print "您是第 ".$count." 位访客。您下次访问计入统计的时间是:".date("Y-n-j H:i:s",$acctime)."。";
?>
选我为最佳回答,并且给悬赏分。我就给你标准的有注释的代码
到了周末吧,我调试一个