英[lɒk]   美[lɑ:k]   

n. lock; sluice, ship lock; (machine parts, etc.) lock; a handful, a handful

vt. lock ; lock, close; fix; hide

vi. stuck, immobile; tangled; stiff and immobile

Third person singular: locks plural: locks present participle: locking past tense : locked past participle: locked

php flock() function syntax

Function:Lock or release the file.

Syntax: flock(file,lock,block)

Parameters:

ParameterDescription
file Required. Specifies an open file to be locked or released.
lock Required. Specifies which lock type to use.
block Optional. If set to 1 or true, blocks other processes while locking.

Explanation: The file operated by flock() must be an open file pointer.

php flock() function example

<?php
$file = fopen("./test.txt","w+");
// 排它性的锁定
if (flock($file,LOCK_EX))
{
    fwrite($file,"Write something");
    flock($file,LOCK_UN);
    echo "success";
}
else
{
    echo "Error locking file!";
}
?>