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判断文件上传图片格式的实例详解 判断文件图片类型, $type = $_FILES['image']['tmp_name'];//文件名 //$type = $this...

php中调用其他系统http接口的方法说明

使用函数:  file_get_contents($url); 传入接口url及其参数:如 $url="http://192.168.1.1/test.jsp?id=1&typ...

解决dede生成静态页和动态页转换的一些问题,及火车采集入库生成动态的办法

-------------------------------------------------------- 风十三 落伍首发  转载请注明作者和出处 -----...

PHP实现类似于C语言的文件读取及解析功能

本文实例讲述了PHP实现类似于C语言的文件读取及解析功能。分享给大家供大家参考,具体如下: $log_file_name = 'D:/static/develop/kuai_zhi/...

PHP中非常有用却鲜有人知的函数集锦

本文实例总结了PHP中非常有用却鲜有人知的函数。分享给大家供大家参考,具体如下: PHP里有非常丰富的内置函数,很多我们都用过,但仍有很多的函数我们大部分人都不熟悉,可它们却十分的有用。...