简体   繁体   English

如何在PHP中获取锁定文件的文件内容

[英]how to get file contents of locked file in PHP

What's the best way, idiomatically, of getting the file contents (into a string) of a flock 'd file in PHP? 什么是最好的方式,习惯用法,得到了文件内容(为一个字符串)的flock倒是在PHP文件?

Edit: To be clear, this is something locked by the current page/process. 编辑:显然,这是当前页面/进程锁定的东西。 Something like: 就像是:

if(flock($fp ...)) {
  $str = READFILECONTENTS($fp);
  flock(...);
}

Don't. 别。 Wait for the lock to be released and only then read it. 等待锁被释放,然后再读取。

Or just read it anyway. 还是无论如何都要阅读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM