Advertisement
Guest User

Untitled

a guest
May 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2.  
  3. //Start settings class.
  4. class Settings {
  5.     static $_instance;
  6.     public $dbname = 'projectdb';
  7.     public $dbhost = '127.0.0.1';
  8.     public $dbuser = 'jiggliemon';
  9.     public $dbpass = 'm0nk3ymon';
  10.        
  11.     // set some globals
  12.     private function __construct($additional)
  13.     {
  14.         if(is_array($additional)){
  15.             foreach($additional as $key=>$val){
  16.                 $this->set($key,$var);
  17.             }
  18.         } else {
  19.             die('You need to give me an array()');
  20.         }
  21.     }
  22.    
  23.     // for security we make it private
  24.     private function __clone(){}
  25.    
  26.    
  27.     public function getInstance($additional)
  28.     {
  29.         // if Settings already is initiated
  30.         // move on
  31.         if(!(self::$_instance instanceof self))
  32.             self::$_instance = new self($additional); // Set if not already in existance.
  33.  
  34.         return self::$_instance;
  35.     }
  36.    
  37.     // Set additional Values
  38.     public function set($key,$value)
  39.     {
  40.         $this->$key = $value;
  41.     }
  42.    
  43.     // Get Values
  44.     public function get($key)
  45.     {
  46.         return $this->$key;
  47.     }
  48.  
  49. } // end settings class
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement