Home >Backend Development >PHP Tutorial >php的计数器每次都会清零

php的计数器每次都会清零

WBOY
WBOYOriginal
2016-06-02 11:34:291056browse

php






$count_num=0;
if(file_exists("counter.txt"))
{
$fp=fopen("counter.txt","r");
$counter_num=fgets($fp,9);//读取前八位数字
$count_num++;
fclose($fp);

}
$fp=fopen("counter.txt","w");
fputs($fp,$count_num);
fclose($fp);

echo" hahaha $count_num hahah";
?>

这个每次显示的都是1 就算人工修改了txt也不行 php初学者 请问问题出在哪里?谢谢!!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn