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+RabbitMQ实现消息队列的完整代码

前言 为什么使用RabbitMq而不是ActiveMq或者RocketMq? 首先,从业务上来讲,我并不要求消息的100%接受率,并且,我需要结合php开发,RabbitMq相较Rock...

解析php通过cookies获取远程网页的指定代码

复制代码 代码如下:function Steal($url, $post_data = ""){//$header[] = "Accept: text/vnd.wap.wml,*.*";...

php使用crypt()函数进行加密

php使用crypt()函数进行加密

一、代码 <?php $str = '应用crypt()函数进行单向加密!'; //声明字符串变量$str echo '加密前$str的值为:'.$s...

php记录代码执行时间(实现代码)

复制代码 代码如下:$t1 = microtime(true);// ... 执行代码 ...$t2 = microtime(true);echo '耗时'.round($t2-$t1,...

PHP将两个关联数组合并函数提高函数效率

在foreach中循环查询数据代码量比较少,但是性能比较低,好点的解决办法是将id收集起来,用in一次性查询,但是这引发了数据结构不是我们用PHP自带的函数可以合并的,今天测试了一下:...