php – file_put_contents上的互斥标志?
在
file_put_contents()文档中,它说明如下:
FILE_APPEND:
LOCK_EX:
然而,下面的几行代码我看到以下代码: <?php $file = 'people.txt'; // The new person to add to the file $person = "John Smithn"; // 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标志是否相互排斥?如果是,为什么他们在示例中使用它?这是一个糟糕的文件案例吗? 感谢您的输入! 解决方法
那只是糟糕的文档.
manual clearly states:
你说的例子是: <?php $file = 'people.txt'; // The new person to add to the file $person = "John Smithn"; // Write the contents to the file,FILE_APPEND | LOCK_EX); ?> 看起来编写这个例子的人误解了“互相排斥”的含义,或者产生了一些秘密的,无证件的行为. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |