简体   繁体   中英

how to read and update the config file in zend framework

when i tried to update the configuration file an exception is thrown
"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>';
}

the xml file

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

when i save it to another file it works but it seems to be locked how to unlock

I think your your "d.xml" is not writable by Apache !?

Your "configs" directory is certainly writable (this work with new file), but not your default file .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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