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

相关文章

Apache2 httpd.conf 中文版

给新手和我看的  #  # 基于 NCSA 服务的配置文件。  #  #这是Apache服务器主要配置文件。&nbs...

隐藏X-Space个人空间下方版权方法隐藏X-Space个人空间标题隐藏X-Space个人空间管理版权方法

版权可以在css中设置隐藏. 由于文件被ZEND所以不能删除,也不建议删除. 1.隐藏X-Space个人空间下方版权方法 修改/css/space.css找到以下代码: /*页...

PHP跳转页面的几种实现方法详解

•PHP页面跳转一、header()函数header()函数是PHP中进行页面跳转的一种十分简单的方法。header()函数的主要功能是将HTTP协议标头(header)输出...

Zend Studio去除编辑器的语法警告设置方法

Zend Studio去除编辑器的语法警告设置方法

环境:Zend Studio 8.0 Zend Studio是PHP开发者的首选开发工具,其地位相当于微软开发工具中的Visual Studio。Zend Studio的编辑器可以帮我...

基于PHP创建Cookie数组的详解

创建:复制代码 代码如下:setcookie("ICNet[Reg]", "This is reg cookie", time() + 3600);setcookie("ICNet[Ac...