微型php框架 include/conf.class.php
<?php
defined('ACC')||exit('Access Denied');
// 配置文件讀取類
class conf {
? ? protected static $ins = null;
? ? protected $cfg = array('db'=>'java0620');
? ??
? ? public static function getIns() {
? ? ? ? if(self::$ins === null) {
? ? ? ? ? ? self::$ins = new self();
? ? ? ? }
? ? ? ? return self::$ins;
? ? }
? ? final protected function __construct() {
? ? ? ? require(ROOT . 'include/config.php');
? ? ? ? $this->cfg = $cfg;
? ? }
? ? // 根據(jù)指定的配置項,返回該配置項的值
? ? public function __get($k) {
? ? ? ? if(!isset($this->cfg[$k])) {
? ? ? ? ? ? return null;
? ? ? ? }
? ? ? ? return $this->cfg[$k];
? ? }
? ? // 根據(jù)指定的配置項,返回配置項的值
? ? public function __set($k,$v) {
? ? ? ? $this->cfg[$k] = $v;
? ? }
}
/*
$conf = conf::getIns();
echo $conf->db,'<br />';
$conf->db = 'java0620';
echo $conf->db;
*/
轉(zhuǎn)載于:https://blog.51cto.com/keyue/1437272
總結(jié)
以上是生活随笔為你收集整理的微型php框架 include/conf.class.php的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (Kali)BackTrack-linu
- 下一篇: MySQL replace into (