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 网页播放器用来播放在线视频的代码(自动判断并选择视频文件类型)

在web开发中经常会碰到一些简单的视频播放功能,但现在的视频格式不同,并且可以动态增加,所以我们就必须把视频保存到数据哦,好了下面我们来看我写的段简单的 php视频网页播放器代码吧。 复...

PHP 字符串加密函数(在指定时间内加密还原字符串,超时无法还原)

这样我们就可以拿此函数来做很多用途了,比如:单点登录的token加密传输啦,临时密码啦等等复制代码 代码如下: /** * @param string $string 原文或者密文 *...

php数据访问之查询关键字

php数据访问之查询关键字

本文实例为大家分享了php查询操作的实现代码,供大家参考,具体内容如下 一、一个关键字查询 主页面: <html> <head> <meta http...

php 将bmp图片转为jpg等其他任意格式的图片

复制代码 代码如下:<? php // 例子: $path = ROOT . ' upload/2009/06/03/124401282315771. ' ; $pathAll =...

php实现可运算的验证码

本文分享了php实现可运算的验证码的代码实例,希望对大家的学习有所帮助。 demo.php代码 <?php session_start(); if(!emptye...