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

相关文章

phpcms的分类名称和类别名称的调用

话不多说,请看代码: //在需要调用的模板前写这句代码,$CATEGORYS 代表分类,$TYPE 代表类别(没有这句话,调不出来) {php $CATEGORYS = getcac...

PHP token验证生成原理实例分析

本文实例讲述了PHP token验证生成原理。分享给大家供大家参考,具体如下: <?php /** * @Author: Ding Jianlong * @Date...

慎用preg_replace危险的/e修饰符(一句话后门常用)

preg_replace函数原型: mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int...

PHP切割汉字的常用方法实例总结

本文实例讲述了PHP切割汉字的常用方法。分享给大家供大家参考,具体如下: <?php /* @UTF-8编码的字符可能由1~3个字节组成。 */ /*---------...

php压缩HTML函数轻松实现压缩html/js/Css及注意事项

压缩HTML的起因 如何提高网页加载速度 ,需要怎么对html页面优化相信是每个拟提高建站技术站长曾想到的问题,其实网页优化的方法还是很多。 有童鞋询问higrid如何 压缩HTML,也...