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中oci8扩展

给大家分享个php操作Oracle的操作类 Oracle_db.class.php <?php class Oracle_db{ public $link; p...

PHP 获取ip地址代码汇总

代码一: function getip() { static $ip = ''; $ip = $_SERVER['REMOTE_ADDR']; if(isset($_SE...

php输出图像的方法实例分析

php输出图像的方法实例分析

本文实例讲述了php输出图像的方法。分享给大家供大家参考,具体如下: PHP作为一种Web语言,无论是解析出的HTML代码还是二进制的图片,最终都要通过浏览器显示。应用GD2函数绘制图像...

yii框架源码分析之创建controller代码

使用yii框架的url路径一般形如hostname/?r=xxxx/xxxx/xxxx&sdfs=dsfdsf 我们可以看到有时会使用protected目录下的controller,有时...