title: Singleton syntax in PHP code
body: <p>I understand the singleton pattern, but I don't understand the following syntax:</p>
  
  <pre><code>    public static function get()
      {
        static $db = null;
        if ( $db == null )
          $db = new DatabaseConnection();
        return $db;
      }
      private function __construct()
      {
        $dsn = 'mysql://root:password@localhost/photos';
        $this-&gt;_handle =&amp; DB::Connect( $dsn, array() );
      }
  </code></pre>
  
  <p>Why every time we call DatabaseConnection::get() we could ge the same singleton object? Because the code read from me will like:</p>
  
  <pre><code>    static $db = null; //set $db object to be null
      if($db==null)  // $db is null at the moment every time because we just set it to be null
        // call the private constructor every time we call get() *
        $db = new DatabaseConnection();  
      return $db;  // return the created 
  </code></pre>
  
  <p>Then how the get() function could always return a same object?</p>
  
  <p>I am new to Php, most of the syntax to me will read like java, please any one could explain this to me?</p>
  
  <p>Also is there any instructions/tutorial that I could read for understanding more syntax sugar like:</p>
  
  <pre><code>       $array_object[] = $added_item
  </code></pre>