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单元测试phpunit入门实例教程

本文实例讲述了php单元测试phpunit。分享给大家供大家参考,具体如下: 这篇文章提供了一些phpunit官方教程没有提到的信息,帮助初学者快速了解php单元测试,在phpunit官...

php中3种方法统计字符串中每种字符的个数并排序

复制代码 代码如下: <?php //这个方法纯粹是背函数,不解释; function countStr($str){ $str_array=str_split($str); $s...

php学习笔记之面向对象编程

复制代码 代码如下:<?phpclass db {     private $mysqli; //数据库连接     p...

php cookie使用方法学习笔记分享

PHP setcookie() 函数向客户端发送一个 HTTP cookie。cookie 是由服务器发送到浏览器的变量。cookie 通常是服务器嵌入到用户计算机中的小文本文件。每当计...