Joomla下利用configuration.php存储简单数据

yipeiwu_com5年前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');

相关文章

vs中通过剪切板循环来循环粘贴不同内容

举个简单的例子,这里有一段代码: 复制代码 代码如下: function Button1_onclick() { alert("Hello"); alert("JacobSong");...

PHP中使用hidef扩展代替define提高性能

网站需要新加一个常量,打开了本地的config.php文件,想到了几年前测试过的hidef以及apc提升define性能的方案。 我的程序中有对开发、测试、生产服务器分别做了不同的配置,...

php实现通过soap调用.Net的WebService asmx文件

本文实例讲述了php实现通过soap调用.Net的WebService asmx文件。分享给大家供大家参考,具体如下: 最近,帮一个同行测试用.net写的WebService接口,C#调...

yum命令安装php7和相关扩展

安装php7和相关扩展 rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.n...

php实现zip文件解压操作

PHP解压zip文件函数,源码简短,需要使用 ZZIPlib library 扩展,使用前请确认该扩展已经开启。 <? /*********************...