繁体   English   中英

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

[英]how to read and update the config file in zend framework

当我尝试更新配置文件时,抛出异常
“无法写入文件”/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>

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

我认为你的“d.xml”不是Apache可写的!

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM