Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
非常に頻繁に増加する値をカウントする PHP ファイルがあります。
<?$totI=515905;?>
場合によっては、別のファイルが $totI 変数をリセットすることがあります (おそらく、2 回同時に読み込みと書き込みを行うためです)。
どうすればこれを修正できますか?
fopen($file,"a")関数の代わりに使用し、関数の後にfopen($file,"w")追加することで修正しましたftruncateflock
fopen($file,"a")
fopen($file,"w")
ftruncate
flock