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匿名函数与注意事项

php5.3不但引进了匿名函数还有更多更好多新的特性了,下面我们一起来了解一下PHP匿名函数与注意事项,具体内容如下 PHP5.2 以前:autoload, PDO 和 MySQLi,...

自动分页的不完整解决方案

测试代码 <form id="form1" name="form1" method="post" action="">  &...

PHP实现AES256加密算法实例

本文实例讲述了PHP实现AES256加密算法的方法,是较为常见的一种加密算法。分享给大家供大家参考。具体如下: aes.class.php文件如下: <?php /*...

php版微信返回用户text输入的方法

本文实例讲述了php版微信返回用户text输入的方法。分享给大家供大家参考,具体如下: 获得用户输入的内容,并发回相同内容 //获取post数据 // $PostData = $HT...

PHP session垃圾回收机制实例分析

本文实例讲述了PHP session垃圾回收机制。分享给大家供大家参考,具体如下: session过期时间 在php.ini文件中有这样一个配置,这个配置表示session文件过期时间,...