In PHP, how can I test if a file has already been locked with flock? For example, if another running script has called the following:
$fp = fopen(\'thefile.t
Check it like this:
if (!flock($file, LOCK_EX)) { throw new Exception(sprintf('File %s is locked', $file)); } fwrite($file, $write_contents);