[PHP] Read and write to a file while keeping lock
- by Znarkus
Hi!
I am making a simple page load counter by storing the current count in a file. This is how I want to do this:
Lock the file
Read the current count
Increment it
Write new count
Unlock file/close it
Can this be done?
As I understand it, the file can't be written to without losing the lock. The only way I have come up with to tackle this, is to write a character using "r+" mode, and then counting characters.