码迷,mamicode.com
首页 > Web开发 > 详细

微型php框架 include/conf.class.php

时间:2014-07-13 14:33:03      阅读:216      评论:0      收藏:0      [点我收藏+]

标签: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;

    }


    // 根据指定的配置项,返回该配置项的值

    public function __get($k) {

        if(!isset($this->cfg[$k])) {

            return null;

        }


        return $this->cfg[$k];

    }


    // 根据指定的配置项,返回配置项的值

    public function __set($k,$v) {

        $this->cfg[$k] = $v;

    }


}




/*


$conf = conf::getIns();


echo $conf->db,‘<br />‘;



$conf->db = ‘java0620‘;


echo $conf->db;


*/


微型php框架 include/conf.class.php,布布扣,bubuko.com

微型php框架 include/conf.class.php

标签:php微型框架

原文地址:http://keyue.blog.51cto.com/6559543/1437272

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!