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');

相关文章

自己前几天写的无限分类类

前一周写的吧,使用中效果还不错。 主要思想来自:http://www.phpobject.net/b...[url=http://www.phpobject.net/blog/...

[PHP]实用函数4

//输出关于PHP和当前请示的信息页面 int phpinfo(void) //返回当前PHP版本号 string phpversion(void) //打印出为本P...

PHP实现CSV文件的导入和导出类

本文实例讲述了PHP实现CSV文件的导入和导出类。分享给大家供大家参考。具体如下: <?php /** * CSV 文件处理类 */ class Csv{ pu...

php 删除一维数组中某一个值元素的操作方法

1. 自己写for循环 从array里去掉$tmp这个元素的值 <?php $tmp = '324'; $arr = array( '0' => '321', '...

php验证码生成器

现在很多网站都有实现用户集。然而为了防止机器人的网络攻击。限制登陆或者注册是有必要的。 在注册和登陆时强制要求输入一个机器难以识别的字符串集是一个不错的选择。虽然不能解决根本问题,但至...