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使用curl判断网页404(不存在)的方法 原创

本文实例讲述了php使用curl判断网页404(不存在)的方法。分享给大家供大家参考,具体如下: <?php /* php使用curl判断404 * Created...

深入理解curl类,可用于模拟get,post和curl下载

如下所示:复制代码 代码如下:<?phpclass Curl { /*  * get 方式获取访问指定地址  * @param  strin...

php curl 获取https请求的2种方法

今天一个同事反映,使用curl发起https请求的时候报错:“SSL certificate problem, verify that the CA cert is OK. Detail...

PHP 转义使用详解

php中数据的魔法引用函数 magic_quotes_gpc  或 magic_quotes_runtime     设置为on时,为...

zend framework配置操作数据库实例分析

zend framework配置操作数据库实例分析

zendframework项目环境搭建后,看了下zend framework配置操作数据库,php教程如下: 在application/configs的文件下建立一个config.ini...