search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Programming Dictionary

Online technical manual for service programmers
Popular searches:
Dictionary homepage Server PHP php flock() function
php flock() function Detailed instructions for use

php flock() function

Chinese translation Recent Updates: 2018-04-19 11:08:21

英[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!";
}
?>
php flock() function