Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('CONFIG_PATHS', 'path');
- define('CONFIG_URLS', 'url');
- define('CONFIG_DATABASE', 'db');
- define('CONFIG_LOGGING', 'log');
- class Config {
- private static $instance = null;
- private $storage;
- function __construct () {
- $this->storage = array();
- }
- public static function GetInstance () {
- if (self::$instance === null) {
- $className = __CLASS__;
- self::$instance = new $className();
- }
- return(self::$instance);
- }
- function setVal ($sNameSpace, $sKey, $sVal) {
- if (is_null($sKey))
- $this->storage[$sNameSpace][] = $sVal;
- else
- $this->storage[$sNameSpace][$sKey] = $sVal;
- }
- function getVal ($sNameSpace, $sKey) {
- if (!array_key_exists($sNameSpace, $this->storage)) return '';
- if (!array_key_exists($sKey, $this->storage[$sNameSpace])) return '';
- return $this->storage[$sNameSpace][$sKey];
- }
- function getVals ($sNameSpace) {
- if (!array_key_exists($sNameSpace, $this->storage)) return array();
- return array_keys($this->storage[$sNameSpace]);
- }
- function hasVal ($sNameSpace, $sKey) {
- return array_key_exists($sKey, $this->storage[$sNameSpace]);
- }
- function delVal ($sNameSpace, $sKey) {
- unset($this->storage[$sNameSpace][$sKey]);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment