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中imagick函数的中文解释

imagick的:: adaptiveBlurImage - 增加了自适应模糊滤镜图像  imagick的:: adaptiveResizeImage - 自适应调整图像数据...

PHP函数积累总结

PHP函数积累总结

字符串 1、strtr(string,from,to)函数 把字符串中的字符from替换成to。 如果from和to长度不同,则格式化为最短的长度。   strtr(stri...

php下检测字符串是否是utf8编码的代码

 function is_utf8($string) {      return preg_ma...

加强版phplib的DB类

复制代码 代码如下:<?php /*************************************************************************...

PHP操作Redis数据库常用方法示例

本文实例讲述了PHP操作Redis数据库常用方法。分享给大家供大家参考,具体如下: Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Val...