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

相关文章

用PHP查询搜索引擎排名位置的代码

复制代码 代码如下:<?php /* 查询谷歌"深圳摄影工作室",岚视界LANSJ的排名位置; 2009-10-11 lost63.com原创 在前30页中搜索 */ $page=...

php实现将Session写入数据库

使用session_set_save_handler()函数,将Session的内容写入数据库 <?php /* *@author Fahy *数据库为m...

php数组函数序列之array_unique() - 去除数组中重复的元素值

array_unique() 定义和用法 array_unique() 函数移除数组中的重复的值,并返回结果数组。 当几个数组元素的值相等时,只保留第一个元素,其他的元素被删除。 返回的...

php 无限极分类

复制代码 代码如下:<?php /*======================================================== 类名:catalog 功能:无...

克隆一个新项目的快捷方式

克隆一个新项目的快捷方式

有没想过最土的项目如何快速复制出一个来,然后改改就成新的团购项目了? 或者说编辑一个老项目的时候想把他另存为一个新项目而不是保存, 看下图 红色部分 具体开发代码(非细节),如下 修改...