<?php
$fp = fopen("/tmp/lock.txt","w+");
if(flock($fp, LOCK_EX)){// 进行排它型锁定
fwrite($fp,"Write something here\n");
flock($fp, LOCK_UN);// 释放锁定
}else{
echo "Couldn't lock the file !";
}
fclose($fp);
?>
<?php
$fp = fopen("/tmp/lock.txt","w+");
if(flock($fp, LOCK_EX)){// 进行排它型锁定
fwrite($fp,"Write something here\n");
flock($fp, LOCK_UN);// 释放锁定
}else{
echo "Couldn't lock the file !";
}
fclose($fp);
?>