Return to Snippet

Revision: 58728
at July 30, 2012 23:39 by ryantxr


Initial Code
class Registry{
   static $entry = array();
   function set($k, $v){
      self::$entry[$k] = $v;
   }
   
   function get($k){
      if ( isset(self::$entry[$k]) ) {
         return self::$entry[$k]      	 ;
      }
      return null;
   }
}

// Set a value
Registry::set('somevar', 'somevalue');
// Get a value
$somevar = Registry::get('somevar');

// Store objects if you want
$pdo = new PDO($dsn, $dbUsername, $dbPassword);
Registry::set('pdo', $pdo);

Initial URL


Initial Description
This class is used to store global information for general access throughout the application.

Initial Title
php Registry class

Initial Tags
php

Initial Language
PHP