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

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

相关文章

什么是OneThink oneThink后台添加插件步骤

什么是OneThink oneThink后台添加插件步骤

OneThink以其便捷的建站、丰富的扩展、灵活的二次开发,以及云服务的支持,为广大个人和企业建站带来新的契机和机遇,即将成为互联网新的弄潮儿。 OneThink特性介绍: 1. 基于T...

php时间不正确的解决方法

2。date_default_timezone_set("PRC");    3。PHP   5.1以上  ...

php 把数字转换成汉字的代码

直接上实例,写到 千亿上了。 /** * @author ja颂 * 把数字1-1亿换成汉字表述,如:123->一百二十三 * @param [num] $num [数字]...

PHP显示今天、今月、上月、今年的起点/终点时间戳的代码

$t = time(); $t1 = mktime(0,0,0,date(“m”,$t),date(“d”,$t),date(“Y”,$t)); $t2 = mktime(0,0,0,d...

攻克CakePHP(PHP中的Ruby On Rails框架)图文介绍第1/2页

攻克CakePHP(PHP中的Ruby On Rails框架)图文介绍第1/2页

CakePHP框架首页: http://www.cakephp.org/ 下载后导入工程中,目录结构如下图(使用版本:1.1.19.6305) 搭建PHP环境,这里使用了AppServ2...