试图使用flock锁定流,但不起作用。
$handle = fopen('/path/to/file.txt', 'r');
flock($handle, LOCK_EX); // Returns true
$handle = fopen('compress.zlib:///path/to/file.txt', 'r');
flock($handle, LOCK_EX); // Returns false
为什么想法为什么?
因为通常不能锁定流——虽然compress.zlib
流确实(通常为*)引用了一个文件,但大多数其他类型的流(如http://
流)并不表示不同的文件,因此锁定它们通常没有意义。
*:嵌套流(例如compress.zlib://http://example.com/
)是一个例外。