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之require/include顺序 推荐

也就有了如下的疑问: include_path是怎么起作用的? 如果有多个include_path顺序是怎么样的? 什么情况下include_path不起作用? 今天, 我就全面的介绍下...

PHPExcel中文帮助手册|PHPExcel使用方法(分享)

下面是总结的几个使用方法 include 'PHPExcel.php'; include 'PHPExcel/Writer/Excel2007.php'; //或者include...

dedecms系统的广告设置代码 基础版本

1.文章内每篇文章的结尾处,顶一下 踩一下的上方的广告位置, 这个位置的大小是658*60 658长度不要变,60高度可以任意改 广告代码添加在这—-后台—–模板—-默认模板管理—-找到...

关于ob_get_contents(),ob_end_clean(),ob_start(),的具体用法详解

ob_get_contents();ob_end_clean();ob_start()使用ob_start()把输出那同输出到缓冲区,而不是到浏览器。然后用ob_get_contents...

PHP Google的translate API代码

新建一个ANSI的PHP文件,然后创建一个类: 复制代码 代码如下:header("Content-Type: text/html; charset=utf-8"); class Goo...