Menu Samaritan's Purse

FLOCK

Portable advisory file locking

SYNTAX

flock ( resource $handle , int $operation [, int &$wouldblock ] ) : bool

PARAMETERS

handle

A file system pointer resource that is typically created using fopen().

operation
LOCK_SH acquire a shared lock (reader)
LOCK_EX acquire an exclusive lock (writer)
LOCK_UN release a lock (shared or exclusive)
LOCK_NB add as a bitmask to one of the above operations if you don't want flock() to block while locking
wouldblock

The optional third argument is set to 1 if the lock would block (EWOULDBLOCK errno condition).

RETURN

Returns TRUE on success or FALSE on failure.

EXAMPLES

HANDLE OPERATION | LOCK_SH

Hello

HANDLE OPERATION | LOCK_EX

Hello

HANDLE OPERATION | LOCK_NB

Hello

WOULDBLOCK

Hello

PHP