Joomla下利用configuration.php存储简单数据

yipeiwu_com5年前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函数实现从一个文本字符串中提取关键字的方法。分享给大家供大家参考。具体分析如下: 这是一个函数定位接收一个字符串作为参数(连同其他配置可选参数),并且定位该字符串中的...

上传文件先创建目录 再上传到目录里面去

1,表单部分: 复制代码 代码如下: <html> <head> <title> my is upfile app!! </title>...

详解WordPress中调用评论模板和循环输出评论的PHP函数

comments_template comments_template 函数是一个调用评论模板的函数,使用起来很简单,与get_header()等函数一样,是一个include文件类函数...

基于header的一些常用指令详解

header常用指令header分为三部分:第一部分为HTTP协议的版本(HTTP-Version);第二部分为状态代码(Status);第三部分为原因短语(Reason-Phrase)...

DOM XPATH获取img src值的query

复制代码 代码如下:$nodes = @$xpath->query("//*[@id='main_pr']/img/@src");$prurl = $nodes->item(...