title: Singleton pattern in php
body: <pre><code>class SingleTon
  {
      private static $instance;
  
      private function __construct()
      {
      }
  
      public function getInstance() {
          if($instance === null) {
              $instance = new SingleTon();
          }
          return $instance;
      }
  }
  </code></pre>
  
  <p>The above code depicts Singleton pattern from this article. <a href="http://www.hiteshagrawal.com/php/singleton-class-in-php-5" rel="nofollow">http://www.hiteshagrawal.com/php/singleton-class-in-php-5</a></p>
  
  <p>I did not understand one thing. I load this class in my project, but how would I ever create an object of Singleton initially. Will I call like this <code>Singelton :: getInstance()</code> </p>
  
  <p>Can anyone show me an Singleton class where database connection is established?</p>