PHP flock() Function
Complete PHP Filesystem Reference Manual
Definition and Usage
The flock() function locks or releases a file.
Returns TRUE on success, or FALSE on failure.
Syntax
flock(file,lock,block)
| Parameters | Description |
|---|---|
| file | Required. Specifies the open file to lock or release. |
| lock | Required. Specifies which type of lock to use.
Possible values: |
Tips and Notes
**Note:** These locks are only used within the current PHP process. If permissions allow, other processes may modify or delete a PHP-locked file.
**Note:** flock() is mandatory under Windows.
**Tip:** The lock can be released via fclose(), which is called automatically when the script finishes.
Example
Complete PHP Filesystem Reference Manual