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 /* 查询谷歌"深圳摄影工作室",岚视界LANSJ的排名位置; 2009-10-11 lost63.com原创 在前30页中搜索 */ $page=...

PHP 实现超简单的SESSION与COOKIE登录验证功能示例

本文实例讲述了PHP 实现超简单的SESSION与COOKIE登录验证功能。分享给大家供大家参考,具体如下:第一步,制作一个提交信息的表单页面这里我不过多叙述,都能懂的把他命名为login...

php让图片可以下载的代码第1/2页

// 文件目录 define(‘DL_DIR', ‘temp/'); // 常见扩展名所对应的MIME类型 $MIMETypes = array( ‘ez' => ‘applica...

基于PHP一些十分严重的缺陷详解

1. 对递归的不良支持递归是一种函数调用自身的机制。这是一种强大的特性可以把某些复杂的东西变得很简单。有一个使用递归的例子是快速排序(quicksort)。不幸的是,PHP并不擅长递归。...

PHP strtotime函数用法、实现原理和源码分析

源码位置:\ext\date\php_date.c 复制代码 代码如下: /* {{{ proto int strtotime(string time [, int now ]) &nb...