[英]Simple PHP hit counter incrementing by two?
我為一個網絡應用程序做了一個點擊計數器,但我很困惑為什么它增加了兩個。 我只是從hitCount.txt文件中設置一個計數器變量,該文件包含一個整數並將預先遞增的值寫回文件。
有問題的代碼:
// get visit count
$wag_file = "hitCount.txt";
$fh = fopen($wag_file, 'r+');
$wag_visit_count = intval(file_get_contents($wag_file));
// increment, rewrite, and display visit count
fputs($fh, ++$wag_visit_count);
fclose($fh);
echo $wag_visit_count . $html_br;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.