这篇文章主要为大家详细介绍了Joomla利用configuration.php存储数据的简单示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随512笔记的小编小韵来看看吧!写入过程
代码如下:
// 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');
注:关于Joomla利用configuration.php存储数据的简单示例的内容就先介绍到这里,更多相关文章的可以留意512笔记的其他信息。
关键词:
您可能感兴趣的文章