在file_put_contents () 文档中,它说明了以下内容:
文件_APPEND:
与 LOCK_EX 互斥,因为追加是原子的,因此没有理由锁定。
LOCK_EX:
与 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 标志是否互斥?如果是,为什么他们在示例中使用它?这是一个糟糕的文档案例吗?
感谢您的输入!