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框架codeigniter中如何使用框架的session

里面有两种session的使用方法:1是php的原始的session使用方法,这个很简单,$_SESSION['name']="name",然后在需要的地方显示:echo $_SESSI...

解析zend studio中直接导入svn中的项目的方法步骤

1.在zend-studio中的项目explorer中右键-》import->选择svn->project from svn-》next-》选择create new ...l...

隐藏你的.php文件的实现方法

隐藏你的.php文件 隐藏你的.php文件  今天做PHP在线手册镜像的时候看到了这个方法,哈哈,以前都没有注意到,所以说,手册是最好的老师 -----------------...

PHP使用GD库输出汉字的方法【测试可用】

PHP使用GD库输出汉字的方法【测试可用】

本文实例讲述了PHP使用GD库输出汉字的方法。分享给大家供大家参考,具体如下: 一、原理 PHP中的GD库支持中文,但是必须要以UTF-8格式的参数来进行传递。下面先说一下汉字的UTF-...

配置eAccelerator和XCache扩展来加速PHP程序的执行

配置eAccelerator和XCache扩展来加速PHP程序的执行

eaccelerator安装配置PHP加速 eAccelerator简介 eAccelerator是一个的免费、开源的PHP模块,它能够为提供PHP加速、优化、加码、和动态内容缓存功能。...