PHP 多进程写文件

$file = fopen("test.txt","w+");
 
// 排它性的锁定 先锁上,写完,打开。
if (flock($file,LOCK_EX))
  {
  fwrite($file,"Write something");
  // release lock
  flock($file,LOCK_UN);
  }
else
  {
  echo "Error locking file!";
  }
 
fclose($file);

猜你喜欢

转载自blog.csdn.net/only_xiaohang/article/details/80914012