Php 文件内容上的互斥标志?

Php 文件内容上的互斥标志?,php,file,locking,flags,Php,File,Locking,Flags,在()文档中,它显示了以下内容: 文件\u追加: 与LOCK_EX互斥自 附属物是原子的,因此存在 没有理由上锁 锁定\u EX: 与文件_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_

在()文档中,它显示了以下内容:

文件\u追加

与LOCK_EX互斥自 附属物是原子的,因此存在 没有理由上锁

锁定\u EX

与文件_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标志是否相互排斥?如果是,他们为什么在示例中使用它?这是一个糟糕的文档吗


谢谢你的意见

那只是糟糕的文档。委员会:

文件\u追加
:如果文件名 已存在,请将数据附加到 文件,而不是覆盖它。 与LOCK_EX互斥自 附属物是原子的,因此存在 没有理由上锁

LOCK\u EX
:获取独占锁 在文件上,同时继续执行 写作。互斥 文件\u追加

你提到的例子是:

<?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);
?>

编写示例的人似乎误解了“互斥”的含义,或者产生了一些秘密的、未记录的行为。

这是手册中的一个错误:请参阅,我在看到此问题/答案后报告了该手册,几分钟前已更正/关闭


(这需要一些时间才能反映在手册的在线版本中,但ahs已在其来源中进行了更正)

没有仔细查看,听起来好像编写示例的人不熟悉文档。或者,在编写示例后,API发生了变化,没有人更新示例。感谢Mark,+1我开始怀疑是否有任何我不知道的模糊原因。这是正确修复的。旗帜不是相互排斥的,这是什么意思?”互斥的