关于file_put_contents () 文档,它说如下:
FILE_APPEND:
Mutually exclusive with LOCK_EX since appends are atomic and thus there is no reason to lock.
LOCK_EX:
Mutually exclusive with FILE_APPEND.
但是,我在下面的几行代码中看到了以下代码:
<?php
$file = 'people.txt';
// The new person to add to the file
$person = "John Smith\n";
// Write the contents to the file,
// using the FILE_APPEND flag to append the content to the end of the file
// and the LOCK_EX flag to prevent anyone else writing to the file at the same time
file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
?>
那么,FILE_APPEND 和 LOCK_EX 标志是否互斥?如果是,他们为什么在示例中使用它?这是不良文档的情况吗?
感谢您的意见!
最佳答案
赞@karim79 said ,这是手册中的错误:请参阅 bug #49329 ,这是我在看到这个问题/答案后报告的,并已在几分钟前更正/关闭。
(在手册的在线版本中需要一些时间,但已在其来源中更正)
关于php - file_put_contents 上的互斥标志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1315055/