Joomla下利用configuration.php存儲簡單數據
更新時間:2010年05月19日 23:45:34 作者:
Joomla下利用configuration.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');
復制代碼 代碼如下:
// 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編程文件處理類SplFileObject和SplFileInfo用法實例分析
這篇文章主要介紹了PHP編程文件處理類SplFileObject和SplFileInfo用法,結合實例形式分析了文件處理類SplFileObject和SplFileInfo的功能、定義、使用方法與相關注意事項,需要的朋友可以參考下2017-07-07
php array_key_exists() 與 isset() 的區(qū)別
這篇文章主要介紹了php array_key_exists() 與 isset() 的區(qū)別的相關資料,需要的朋友可以參考下2016-10-10

