当前位置:首页 > PHP教程 > PHP高级教程

Joomla下利用configuration.php存储简单数据

写入过程
复制代码 代码如下:

// get the path of the configuration file
$fname = jpath_configuration.ds.'configuration.php';
// clear cache
$cache = jfactory::getcache();
$cache->clean();
// update the credentials with the new settings
$config =& jfactory::getconfig();
$config->setvalue('config.custom_var', 'xxx');
// get the config registry in php class format and write it to configuation.php
jimport('joomla.filesystem.file');
if (!jfile::write($fname, $config->tostring('php', 'config', array('class' => 'jconfig')))) {
die(jtext::_('errorconfigfile'));
}

提取过程
复制代码 代码如下:

global $mainframe;
$mainframe->getcfg('custom_var');

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!