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中两种缩放图片的函数,为图片添加水印

有两种改变图像大小的方法.(1):ImageCopyResized() 函数在所有GD版本中有效,但其缩放图像的算法比较粗糙.(2):ImageCopyResampled(),其像素插值...

解析 thinkphp 框架中的部分方法

 1 thinkphp 框架 中判断输入的数值和数据库中的数值是否一致    首先 需要在view文件夹下建一个模板 名为zhuce.html <...

一个简单安全的PHP验证码类 附调用方法

一个简单安全的PHP验证码类 附调用方法

一、验证码示例 二、php验证码类,secoder.class.php <?php /** * 安全验证码 * * 安全的验证码要:验证码文字扭曲、旋转,...

Discuz 6.0+ 批量注册用户名

1.将adduser.php复制到discuz根目录下; /--adduser.php内容如下--/ <? php require_once './include/common.i...

PHP注释实例技巧

复制代码 代码如下:<?php $a = 1; $b = 2; if (1==1) { $andy = '帅哥'; } ?> 一般注释的时候,用 复制代码 代码如下:<...