1. 首页
  2. 数据库
  3. 其它
  4. PHP文件锁定写入实例解析

PHP文件锁定写入实例解析

上传者: 2020-12-23 00:34:59上传 PDF文件 37.66KB 热度 9次
本文以实例讲述了PHP文件写入方法,以应对多线程写入,具体代码如下: function file_write($file_name, $text, $mode='a', $timeout=30){ $handle = fopen($file_name, $mode); while($timeout>0){ if ( flock($handle, LOCK_EX) ) { // 排它性的锁定 $timeout--; sleep(1); } } if ( $timeout > 0 ){ fwrite($handle,
下载地址
用户评论