简单的计数器问题??
计数器函数:
counter.inc
<?php
//一个简单的计数器
function get_hitcount($counter_file)
{
$count=0;
if (file_exists($counter_file))
{
$fp=fopen($conuter_file,"r+");
$count=0+fgets($fp,20);
fclose($fp);
//操作文件完毕
}
$count++;
$fp=fopen($counter_file,"w+");
fputs($fp,$count);
fclose($fp);
return ($count);
}
?>
主页面:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<?php
include ("includes/common.inc");
$title="welcome";
include ("includes/header.inc");
?>
<p>欢迎来我的网页</p>
<?php
include("includes/counter.inc");
printf("<center><b>%08d</b></center><br>\n",get_hitcoun("C:\\ProgramFiles\\ApacheGroup\\Apache\\htdocs\\includes\\counter.txt"));
?>
</body>
</html>
我是在windows xp下建立的服务器,我做了个简单计数器counter.inc,而执行第一次时,页面出现00000001,系统中有counter.txt文件产生,但当我再次打开该页面时,系统提示counter.inc 中的
if (file_exists($counter_file))
{
$fp=fopen($conuter_file,"r+");
$count=0+fgets($fp,20);
fclose($fp);
//操作文件完毕
}
上面语句中的:
$count=0+fgets($fp,20);
fclose($fp);出错?
请问各位大虾们〉帮帮小弟的忙吧!!,谢谢了