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设计模式之观察者模式定义与用法示例

本文实例讲述了PHP设计模式之观察者模式定义与用法。分享给大家供大家参考,具体如下: <?php /** * Interface Observable * defi...

php中的时间显示

 方法1:  //list($first,$second)=explode(" ",$date_temp);     ...

PHP通过get方法获得form表单数据方法总结

PHP通过get方法获得form表单数据方法总结

我们在进行网页交互设计的时候,通常都会使用PHP中get变量方法来获得form表单中的数据,以此来实现各种网页动态查询或者请求。对于稍有HTML基础的朋友来说,应该都知道HTML for...

PHP编程之设置apache虚拟目录

PHP编程之设置apache虚拟目录

apache虚拟目录设置方法分享,供大家参考,具体内容如下 1.开启“虚拟目录配置文件”httpd-vhosts.conf 文件路径:\wamp\bin\apache\apache2.4...

php获取数组中重复数据的两种方法

(1)利用php提供的函数,array_unique和array_diff_assoc来实现 复制代码 代码如下: <?php function FetchRepeatMember...