flock

bool flock(resource file_handle, int operation) 

Locks or releases a file.

Returns:

TRUE on success; FALSE on error

Description:

This function can put a lock on a file or release a previously established lock. Depending on the value of the operation, you have the following options:

Operation Action
1 Acquire a shared lock (reader)
2 Acquire an exclusive lock (writer)
3 Release a lock

A shared lock is a so-called reader lock that should be used if you intend only to read from a file. This ensures that the file remains intact for reading while still allowing other processes to access the file.An exclusive lock is a writer lock that should be used if you intend to change a file. This type of lock prevents other processes from accessing ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.