我不断收到此代码的错误,即使当我在浏览器中运行它时它应该正常工作,但是当它调用include_once
它时由于错误而不起作用
foreach(($hostlist->uploaded) as $uploaded) {
if (strcmp($uploaded->url,"http://someurl.com/")==0) {
$host = simplexml_load_file($config['hostlist']);
unset($host->uploaded->url);
unset($host->uploaded->pass);
$host->uploaded->addChild('url',"http://anotherurl.com/");
$host->uploaded->addChild('pass',"anotherpass");
$host->uploaded->asXML($config['hostlist']);
$host->asXML($config['hostlist']);`
echo "URL Changed to http://anotherurl.com/";
}
}
知道变量如下:
$config['hostlist'] = 'xml/host.xml';
$hostlist = simplexml_load_file($config['hostlist']);
这是 xml 文件的示例:
<host>
<uploaded>
<work>yes</work>
<url>http://someurl.com/</url>
<pass>pass</pass>
</uploaded>
</host>