title: Using Registry class instead of Global variables. How to make it better
body: <p>I am trying to create a better registry class, so  I don't have to declare global variables like some database connections, using sensitive information in a global variable.</p>
  
  <p>Here is an idea which I found online in some tutorial. I would like to ask if it is OK, or we can make it better in some other way?</p>
  
  <pre><code>class registry {
      private $register = array();
  
       public function __set($index, $value)  {
          $this-&gt;register[$index] = $value;
       }
       public function __get($index)  {
          return $this-&gt;register[$index];
       }
  }
  </code></pre>