刚做的一个网页计数器 大家参考一下

时间:2022-05-10 03:40:22
<?
$counterFile="counter.txt";
$fp=fopen($counterFile,"r+");
$num=fgets($fp,10);
if(!$count){
$second=3600;
setcookie("count",1,time()+$second);
  $num+=1;
rewind($fp);
flock($fp,2);
fwrite($fp,$num);
}
  fclose($fp);
  function echoimg($n){
  $l=strlen($n);
for($i=0;$i<$l;$i++){
$img=substr($n,$i,1);
echo "<img src=/"".$img.".gif/">";
  }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>记数器</title>

</head>

<body>

<div id="Layer1" style="position:absolute; left:158px; top:43px; width:191px; height:60px; z-index:1">你是本页面第<? echoimg($num);?>个访客</div>
</body>
</html>