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实现简单的守护进程创建、开启与关闭操作。分享给大家供大家参考,具体如下: 前提要安装有pcntl扩展,可通过php -m查看是否安装 <?php c...

PHP去除数组中重复的元素并按键名排序函数

1、此函数的作用:去除数组中重复的元素并按键名排序 function assoc_unique($arr, $key) { $tmp_arr = array(); foreach($ar...

ThinkPHP实现递归无级分类——代码少

具体代码如下: /** * 无级递归分类 * @param int $assortPid 要查询分类的父级id * @param mixed $tag 上...

PHP 向右侧拉菜单实现代码,测试使用中

这个是由asp二级侧拉菜单改的 复制代码 代码如下: <script language="javascript"> // JavaScript Document startL...

PHP操作XML中XPath的应用示例

本文实例讲述了PHP操作XML中XPath的应用。分享给大家供大家参考,具体如下: XPath即为XML路径语言,它是一种用来确定XML(标准通用标记语言的子集)文档中某部分位置的语言。...