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 移除数组重复元素的一点说明

如:复制代码 代码如下:$test_array=array(1,2,3,4,4,5,5,6); $test_array_unique=array_unique($test_array);...

PHP实现的构造sql语句类实例

本文实例讲述了PHP实现的构造sql语句类。分享给大家供大家参考,具体如下: /** * @package Database Class * @author injection (m...

curl 出现错误的调试方法(必看)

实例如下: private function httpGet($url) { $curl = curl_init(); curl_setopt($curl,...

php源码的使用方法讲解

PHP程序都要用MYSQL,如果没有MYSQL,就不能用它们. 第一:配置数据库信息,改成自己所需的; 第二:导入数据库; 第三:安装wamp5 输入 http://127...

PHP遍历数组的方法汇总

今天有个朋友问我一个问题php遍历数组的方法,告诉她了几个。顺便写个文章总结下,如果总结不全还请朋友们指出 第一、foreach() foreach()是一个用来遍历数组中数据的最简...