It can be used to lock the file
Example
<?php
$fp = fopen(“test.txt”, “r+”);
flock($fp, LOCK_EX); // acquire an exclusive lock (writer).
flock($fp, LOCK_SH); // acquire a shared lock (reader).
flock($fp, LOCK_UN); // unlock the file
fclose($fp);
?>