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');

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...