php勉強中です
カウンターを造るところで一つ疑問点が
<?php
$fp = fopen("count.txt", "r+");
$iCount = fgets($fp, 64);
flock($fp, 2);
fseek($fp, 0);
$iCount++;
fputs($fp, $iCount);
fclose($fp);
print $iCount;
?>
だとカウントがあがらない
$iCount++;を$iCount = $iCount + 1;にするとカウントがあがります。
$iCount++;が効かないのかと思いましたが
違うスクリプトで
<?php
$filename = "count.dat";
$file = fopen($filename, "r+");
flock($file,2);
$count = fread($file, filesize($filename));
$count++;
print "$count";
rewind($file);
fwrite($file, $count);
flock($file,3);
fclose($file);
?>
これだとカウントが上がります
どなたか説明していただけないでしょうか