?????????????
????1???????????????
????2?????????д???????????
????3???????????????????????
????????????ó???
????1????ó?????????????????????????????л????????????????????????????????????????????????????????????????new?????????????new?????????????????????????
????2??WEB?????е??????????????????????????????
????3??redis?????memcached????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????д????????????ο???
??????????????д?????
<?php
/**
*?????????????????????????????????????????????????????????????????????д????????????ο???
*/
class Conf {
//?????????????????????????private
static private $_instance = null;
private $_settings = [];
//??????????????????????
static function getInstance() {
//??η???????????????????????????????????
if (self::$_instance == null) {
self::$_instance = new Conf();
}
//????conf?????
return self::$_instance;
}
//???????????? new ?? clone????????????????????????????е? construct ?? clone
private function __construct() {}
private function __clone() {}
//?????????
function set($index?? $value) {
//????????????????????????????
$this->_settings[$index] = $value;
}
//????????
function get($index) {
//????????????????????????????
return isset($this->_settings[$index]) ? $this->_settings[$index] : '';
}
}