Advertisement
Guest User

Untitled

a guest
Feb 4th, 2011
1,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. <?php
  2. class Config
  3. {
  4.     private $vars;
  5.     private static $instance;
  6.  
  7.     private function __construct()
  8.     {
  9.         $this->vars = array();
  10.     }
  11.  
  12.     //Con set vamos guardando nuestras variables.
  13.     public function set($name, $value)
  14.     {
  15.         if(!isset($this->vars[$name]))
  16.         {
  17.             $this->vars[$name] = $value;
  18.         }
  19.     }
  20.  
  21.     //Con get('nombre_de_la_variable') recuperamos un valor.
  22.     public function get($name)
  23.     {
  24.         if(isset($this->vars[$name]))
  25.         {
  26.             return $this->vars[$name];
  27.         }
  28.     }
  29.  
  30.     public static function singleton()
  31.     {
  32.         if (!isset(self::$instance)) {
  33.             $c = __CLASS__;
  34.             self::$instance = new $c;
  35.         }
  36.  
  37.         return self::$instance;
  38.     }
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement