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 模拟登陆MSN并获得用户信息

复制代码 代码如下:<?php /* * PHP100中文网,整体提供,测试通过 */ $msn = new myMSN(php100@php100.com, "123"); //...

php 8小时时间差的解决方法小结

原来从php5.1.0开始,php.ini里加入了date.timezone这个选项,默认情况下是关闭的 也就是显示的时间(无论用什么php命令)都是格林威治标准时间 和我们的时间(北京...

关于php unset对json_encode的影响详解

关于php unset对json_encode的影响详解

前言 PHP 中有个释放变量的语句叫做unset(从PHP4开始unset已经不再是一个函数了,而是一个语句),本文主要给大家介绍了关于php unset对json_encode影响的相...

解决GD中文乱码问题

今天仔细研究了下GD的一些相关技术,顺手也研究下GD中文乱码的问题。  使用GD库输出中文字符串,调用imagestring是没有用的。需要使用imagettftext()函数...

php class类的用法详细总结

一:结构和调用(实例化): class className{} ,调用:$obj = new className();当类有构造函数时,还应传入参数。如$obj = new classN...