如何在Zend框架中读取和更新配置文件

3
当我试图更新配置文件时,会抛出一个异常:"Could not write to file "/opt/lampp/htdocs/fashion/application/configs/d.xml"
$xml=ROOT_PATH.'/application/configs/d.xml';
$config=new Zend_Config_Xml($xml,null,true);
$conf_arr=$config->toArray();
$conf_arr['name']='somebody';
$conf_writer=new Zend_Config_Writer_Xml();
try 
{
  $conf_writer->write($xml,new Zend_Config($conf_arr),false);
} catch (Exception $e) 
{
  echo '<h1 style="color:red;">'.$e->getMessage().'</h1>';
}

XML文件
<?xml version="1.0" encoding="UTF-8"?>
<data>
    <name>ahmed</name>
    <living>Saudi Arabia</living>
</data>

当我将它保存到另一个文件时,它可以工作,但似乎被锁定了,如何解锁?

1个回答

2

我认为您的 "d.xml" 文件无法被Apache写入!?

您的 "configs" 目录肯定是可写的(这适用于新文件),但默认文件不可写。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接