【发布时间】:2015-06-14 14:21:49
【问题描述】:
我知道对于这个确切的问题有很多答案,但似乎没有一个可以帮助我解决我的问题。
我的服务器上有一个 xml 文件,我需要使用 PHP SimpleXML 从文档中删除一个元素。经过一番谷歌搜索后,我发现了一些答案说要使用 unset() 然后保存 xml。
所以我想出了这个:
function deleteCourse($course){
$xml = self::getxml(); # get the XML file
unset($xml->xpath('course[name = "'.$course.'"]'));
$xml->asXml("data.xml");
}
现在每当我运行此程序时,我都会收到此错误:PHP Fatal error: Can't use method return value in write context in blahblahLink on line 92
第 92 行是unset($xml->xpath('course[name = "'.$course.'"]'));
我真的希望有人可以帮助我解决这个问题
【问题讨论】: