title: Why my Registry pattern implementation not working?
body: <p>Am I missing something? Or am I misunderstanding the concept?</p>
  
  <p>From my current understanding of the design pattern of Registry, the file test.php should print the name "MIH406", but it didn't! Why?</p>
  
  <p>First I visited index.php page, then I visited test.php page.</p>
  
  <p>Does it work like that?</p>
  
  <p>I want to learn the concept behind Registry whether it is considered good or bad, so please no need to re-open a discussion here about how good or how bad this pattern, thanks.</p>
  
  <p>NOTE: I am testing it under my pc with Ubuntu and LAMP</p>
  
  <p>Here is my simple implementation:</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;?php
  require_once "registry.php";
  
  Registry::getInstance()-&gt;set("name", "MIH1406");
  ?&gt;
  </code></pre>
  
  <p>test.php</p>
  
  <pre><code>&lt;?php
  require_once "registry.php";
  
  echo Registry::getInstance()-&gt;get("name");
  ?&gt;
  </code></pre>
  
  <p>registry.php</p>
  
  <pre><code>&lt;?php
  class Registry
  {
      private static $_instance = null;
      private $_registry = array();
  
      public static function getInstance()
      {
          if(self::$_instance == null)
          {
              self::$_instance = new Registry();
          }
          return self::$_instance;
      }
  
      public function set($key, $value)
      {
          $this-&gt;_registry[$key] = $value;
      }
  
      public function get($key, $default = null)
      {
          if(!isset($this-&gt;_registry[$key]))
          {
              return $default;
          }
  
          return $this-&gt;_registry[$key];
      }
  
      private function __construct()
      {
      }
  
      private function __clone()
      {
      }
  }
  ?&gt;
  </code></pre>