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中spl_autoload_register函数的用法总结

spl_autoload_register(PHP 5 >= 5.1.2)spl_autoload_register — 注册__autoload()函数 说明bool spl_a...

php出现web系统多域名登录失败的解决方法

本文实例讲述了php出现web系统多域名登录失败的解决方法,分享给大家供大家参考。具体分析如下: 下面只是简单的逻辑结构,对于正式的系统需要做具体的处理。 这里需要注意的是:加解密一定需...

PHP开启opcache提升代码性能

配置指令如下: [opcache] zend_extension=opcache.so opcache.enable_cli=1 ;共享内存大小, 这个根据你们的需求可调 opcac...

php使用json_decode后数字对象转换成了科学计数法的解决方法

本文实例讲述了php使用json_decode后数字对象转换成了科学计数法的解决方法。分享给大家供大家参考,具体如下: 问题: 今天在搞网页游戏在facebook积分上的对接,faceb...

php中使用Curl、socket、file_get_contents三种方法POST提交数据

抓取远程内容,之前一直都在用file_get_content函数,其实早就知道有curl这么一个好东西的存在,但是看了一眼后感觉使用颇有些复杂,没有file_get_content那么简...