Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试存储 xml 节点的值并保持它相同,即使它更新。
如果我做:
$sxml->node = 1; $blah = $sxml->node; echo($blah . "<br />"); $sxml->node = 2; echo($blah . "<br />");
输出将是
1 2
无论 $sxml->node 发生什么,我都希望 $blah 保持不变。我该怎么做?
将给出的 SimpleXML 对象类型$sxml->node转换为字符串:
$sxml->node
$blah = (string) $sxml->node;
这可以防止对象的属性被更新。