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

yipeiwu_com5年前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');

相关文章

PHP实现的浏览器检查类

本文实例讲述了PHP实现的浏览器检查类。分享给大家供大家参考,具体如下: <?php //原作者:epsilon7 //SonyMusic([email]sonymus...

PHP实现在线阅读PDF文件的方法

本文实例讲述了PHP实现在线阅读PDF文件的方法。分享给大家供大家参考。具体实现方法如下: <?php if(!function_exists('read_pdf'))...

php计算title标题相似比的方法

本文实例讲述了php计算title标题相似比的方法。分享给大家供大家参考。具体如下: <?php /* * * @param string $title_1 题目...

IIS7.X配置PHP运行环境小结

IIS7.X配置PHP运行环境小结

一、使用IIS运行PHP程序 1.首先下载PHP,这里我下载的是php5.2.14(如果是其他高版本的话可能找不到php5isapi.dll,其相关配置方法暂且不论),建议下载zip压...

php5.2时间相差8小时

在PHP5中,在php.ini里修改 date.timezone = "Asia/shanghai" 就行了 ...