文本型计数器会不会出现读写共享冲突的现象啊?
我写了一个文本型计数器,主要代码如下
<?
function writefile($filepath,$data="",$mode="w"){
$fp = fopen($filepath,$mode);
fwrite($fp,$data);
fclose($fp);
}
$totalcount=0;
$filepath = "totalcount.php";
if(file_exists("$filepath")){
include("$filepath");
}
$totalcount++;
writefile($filepath,"<"."? \$totalcount=$totalcount; ?".">");
?>
可是不时出现计数重新开始的情况,就是昨天明明有几万了,今天一看又变成几千了.
百思不得其解...
会不会是因为该文件读写冲突,而使数据读不进来呢?
PS:目前的日访问量有一万左右