zl程序教程

您现在的位置是:首页 >  后端

当前栏目

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

PHP存储数据 简单 利用 configuration Joomla
2023-06-13 09:14:18 时间
写入过程
复制代码代码如下:

//Getthepathoftheconfigurationfile
$fname=JPATH_CONFIGURATION.DS."configuration.php";
//clearcache
$cache=JFactory::getCache();
$cache->clean();
//Updatethecredentialswiththenewsettings
$config=&JFactory::getConfig();
$config->setValue("config.custom_var","xxx");
//GettheconfigregistryinPHPclassformatandwriteittoconfiguation.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");