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实现的简单数据库操作Model类

本文实例讲述了php实现的简单数据库操作Model类。分享给大家供大家参考,具体如下: 该数据库模型类可实现数据库的增删改查,简化数据库操作。 1. config.php代码: &l...

php如何实现只替换一次或N次

 我们都知道,在PHP里Strtr,strreplace等函数都可以用来替换,不过他们每次替换的时候都是全部替换,举个例子: "abcabbc",这个字符串如果使用上边的函数来...

php采用ajax数据提交post与post常见方法总结

本文实例讲述了php采用ajax数据提交post与post常见方法。分享给大家供大家参考。具体方法如下: 在很多情况下我们使用ajax是不会有什么问题的,但有时会碰到ajax数据提交po...

PHP输出一个等腰三角形的方法

本文实例讲述了PHP输出一个等腰三角形的方法。分享给大家供大家参考。具体实现方法如下: function isosceles($line,$sing){ $tab ='=';...

php中使用base HTTP验证的方法

本文实例讲述了php中使用base HTTP验证的方法。分享给大家供大家参考。具体如下: function http_auth($un, $pw, $realm = "Secured...