php - file_put_contents 上的互斥标志?

标签 php file locking flags

关于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/

相关文章:

PHP PDO 双插入

php - 试图使用 php 函数返回数组查找 gcd?

php - 使用SMTP,PHPmailer发送邮件时如何知道用户发送和阅读邮件

mysql - 防止 MySQL 脏读阻塞显式写锁?

Python:锁定目录

php - 使用 php 和 smtp 进行电子邮件验证

c++ - 我无法标记我的角色,我该如何到达那里?

file - 将csv文件复制到lua中的新文件

python - 安全的加密签名必须驻留在它所引用的文件之外吗?

Python:在没有Lock机制的情况下通过多线程并发访问一个函数