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中文乱码问题的终极解决方案,分享出来供大家参考学习,在开始之前,我们先来谈谈为什么会出现中文乱码? 很多新手朋友学习PHP的时候,发现程序中的中文在...

php 获取远程网页内容的函数

<?php $curDomain = $_SERVER['HTTP_HOST']; $strHTML = file_get_contents('//www.jb51.net/Dom...

PHP优于Node.js的五大理由分享

作者Jani Hartikainen发表了一篇博文,文中将两者进行对比,列举了PHP优于Node.js的五大理由。一起来看下。 1. 容易托管 大多数Web托管服务器提供商能为PHP提供...

php中用date函数获取当前时间有误的解决办法

初学PHP做网站,想在页面上获得当前时间,学过编程的人都知道用时间函数date(),先用这个函数格式化一个本地时间/日期,先写个测试代码吧,结果输出时间比实际时间少了8小时,这是什么原因...

php 文章调用类代码

调用方法如下: 复制代码 代码如下: $Template= '<li class="xxx">[<a href="{catedir}">{catetitle}&l...