title: PHP Late Static Binding in Singleton
body: <p>I has this code from some article on habrahabr.ru:</p>
  
  <pre><code>abstract class Singleton {
  
      protected static $_instances = array();
  
      protected function __construct() {
      }
  
      public static function getInstance() {
  
              $class = \get_called_class();
              if ( !isset( static::$_instances[$class] ) )
                      static::$_instances[$class] = new static;
  
              return static::$_instances[$class];
  
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Auhtor use it as, for example,</p>
  
  <pre><code>class B extends Singleton {
  
      private $_a = 10;
  
  }
  </code></pre>
  
  <p>But I can not to understand main difference between "static" and "self" in this case: for example, if we define $_instances as public and try to create some another class like</p>
  
  <pre><code>class C extends Singleton {
  
      private $_z =  55;
  
  }
  </code></pre>
  
  <p>and define Singleton as not abstract class, after each call of getInstance we have <strong>the same</strong> array of instances in both cases: with static::$_instances and self::$_instances:</p>
  
  <pre><code>$s = Singleton::getInstance();
  
  print_r(Singleton::$_instances);
  print_r(B::$_instances);
  print_r(C::$_instances);
  
  $b_instance = B::getInstance();
  
  print_r(Singleton::$_instances);
  print_r(B::$_instances);
  print_r(C::$_instances);
  
  $c_instance = C::getInstance();
  
  print_r(Singleton::$_instances);
  print_r(B::$_instances);
  print_r(C::$_instances);
  </code></pre>
  
  <p>Can anobody help me and tell me, why $_instances arrays are same, and why author use static, not self? Thank you very much, sorry for my English.</p>