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实现的二分查找算法示例

本文实例讲述了php实现的二分查找算法。分享给大家供大家参考,具体如下: <?php $arr = array(4,58,11,34,88,45,32,54,63,78...

解析关于java,php以及html的所有文件编码与乱码的处理方法汇总

php文件中在乱码(如a.php文件在浏览器乱码):header("Content-Type:text/html;charset=utf-8")是设置网页的。mysql_query("s...

php使用scandir()函数扫描指定目录下所有文件示例

本文实例讲述了php使用scandir()函数扫描指定目录下所有文件。分享给大家供大家参考,具体如下: //遍历子文件夹和文件夹的内容 并且计算出文件的多少 //一个demo 引号替...

php进行ip地址掩码运算处理的方法

本文实例讲述了php进行ip地址掩码运算处理的方法。分享给大家供大家参考,具体如下: ip解析: function ip_parse($ip_str) { $mark_len =...

PHP正则验证字符串是否为数字的两种方法并附常用正则

php 正则验证字符串是否为数字 方法一: php中利用正则表达式验证字符串是否为数字一件非常容易的事情,最主要的是如何写好正则表达式以及掌握正则表达式的写法,在此利用正则表达式的方式来...