There is a way to lock a file while accessing it in PHP. If two people did try to edit at the same time, one would simply fail.
There is a way to lock a file while accessing it in PHP. If two people did try to edit at the same time, one would simply fail.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Thanks John. Do you know how to do that? If not, I'll google around.
In PHP 5+ if using the the file_put_contents function (combines file handle, file open and write from previous versions) to write to the file, you can use the LOCK_EX flag to prevent any other attempts at writing to the file during the operation. See:
http://php.net/manual/en/function.file-put-contents.php
Just opening and writing to a file is more complex in PHP 4, but I believe a similar thing can be done during the write phase.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
molendijk (09-16-2014)
Thank you so much, John! I'm indeed using file_put_contents.
Bookmarks