0
$f = fopen($file . '.lock', 'w');
flock($f, LOCK_SH);
$data = file($file);
flock($f, LOCK_UN);
fclose($f);
unlink($file . '.lock');

I saw this as one of the suggestions on this question on locking a file when using file() method to read.

file lock is obtained on $file.'.lock' while file read is done on $file using the file() method.

shouldn't file read be done on $file.lock file on which lock is obtained?

0 Answers0