php file lock writing PHP file writing method, coping with multi-threaded writing:
The handle operated by flock(int $handle, int $operation) function must be an open file pointer. operation can be one of the following values: To obtain a shared lock (reading program), set operation to lock_sh (set to 1 in versions prior to PHP 4.0.1). To obtain an exclusive lock (writing program), set operation to lock_ex (set to 2 in versions prior to PHP 4.0.1). To release a lock (whether shared or exclusive), set operation to lock_un (set to 3 in versions prior to PHP 4.0.1). If you don't want flock() to block on lock, add lock_nb (set to 4 in versions prior to PHP 4.0.1) to the operation. |