我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

使用file()方法时,php文件锁定

$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?

近期文章

  • 为每个img元素添加活动类
  • 如何减少Couchbase上的查看呼叫?
  • 从数据库获取信息时出现PHP错误[重复]
  • imagefilter不会完全覆盖边缘
  • 将<br />转换为<p>标签以标准化文本
  • 如何使用PHP获取/见解/ page_fans_country /?
  • 在更新之前删除最后一条记录
  • FFMpeg在命令行中工作,但不在shell_exec中工作
  • 使用SILEX获取PUT路由中的数据
  • $ wpdb-> get_results在服务器上不返回任何内容,但适用于本地 - Wordpress
  • Php在特定位置添加数组中的元素
  • 使用外部数据库验证Android APP中的用户凭据
  • 发布到linkedin组不作为促销
  • Laravel 4.2无法使用Localization复数
  • Fine Uploader - 按表单而不是AJAX提交
  • Symfony2自定义算法密码编码器
  • 在注册表中检查用户名
  • 用Ajax调用PHP方法[重复]
  • SHA 256 for android app [复制]
  • 使用exec()和PHP运行命令

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华