Joomla下利用configuration.php存储简单数据

yipeiwu_com5年前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');

相关文章

解决ThinkPHP下使用上传插件Uploadify浏览器firefox报302错误的方法

最近用ThinkPHP开发一个项目,集成了批量上传文件插件Uploadify,在谷歌Chrome和IE下都能正常上传,只有火狐下提示这个错误,网上找了很多解决办法,基本都说flash在f...

PHP下使用CURL方式POST数据至API接口的代码

其实,也比较简单,上代码:复制代码 代码如下:<?php          $url = 'http...

PHP字符串与数组处理函数用法小结

本文实例讲述了PHP字符串与数组处理函数用法。分享给大家供大家参考,具体如下:字符串处理函数trim --去除字符串首尾的多余空白字符和其他字符函数结构:string trim&...

php使用curl实现简单模拟提交表单功能

php使用curl实现简单模拟提交表单功能

php 使用curl 进行简单模拟提交表单,供大家参考,具体内容如下 //初始化curl $ch = curl_init(); $url = 'xxx'; $option = [...

PHP获取中国时间(上海时区时间)及美国时间的方法

本文实例讲述了PHP获取中国时间(上海时区时间)及美国时间的方法。分享给大家供大家参考,具体如下: 中国时间: /** * 获取中国时间,即上海时区时间 * @param <...