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数组游标实现对数组的各种操作。分享给大家供大家参考,具体如下: 如何不用foreach实现对数组实现循环? 答:我们只需要模拟foreach就行了,数组在执行...

PHP检查端口是否可以被绑定的方法示例

本文实例讲述了PHP检查端口是否可以被绑定的方法。分享给大家供大家参考,具体如下: <?php /** * 检查端口是否可以被绑定 * @author flynet...

Yii2框架实现注册和登录教程

Yii2框架实现注册和登录教程

注册 在advanced模板中,进入frontend/index.php?r=site%2Fsignup页面,可以看到框架的注册页面 填写完Username、Email和Pa...

PHP中cookie知识点学习

什么是cookie cookie,即小饼干,是保存在用户代理端(浏览器是最常见的用户代理)的一些数据片段。浏览网页时,浏览器会将 当前页面有效的 cookie放在请求的头部发送到服务端。...

php生成短域名函数

php生成短域名函数 public function createRandCode($string) { $code = ''; $hex_code = '1qaz2...