如何使用 php 中的 xml 文件保护 read/write 交易

How is it possible to protect read/write transactions with xml file in php

从 facebook 聊天中我收到了请求,该请求更改了 xml 文件中的一些信息(在 php 上编码)。接下来是鳕鱼:

$participants = simplexml_load_file($fname);
//change,add,delete nodes
$participants->asXML($fname);

例如,如果请求 1 和 2 将在某一时刻用 simplexml_load_file 读取相同的 xml 文件,并且在请求 1 将信息放入其中后,下一个请求将用他的擦除写上次请求的信息。有可能以某种方式管理它吗?例如数据库中的交易?

您应该为该文件设置文件权限以防止其写入

$permission = chmod ("/yourdir/yourfile.txt", 0600);

// Read and write for owner, nothing for everybody else

注:

您应该给出您可以查找的从根文件夹开始的确切文件路径。

Here是越多文件权限