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

发表于:2007-06-08来源:作者:点击数: 标签:
? $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=s
<?
$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>

原文转自:http://www.ltesting.net