求助一个莫名其妙的php问题

请看下面的代码:
  1. <?php
  2. class Singleton{
  3.     private static $instance;

  4.     private function __construct(){
  5.         self::$instance = &$this;
  6.         echo '<br/>','====0','<br/>';
  7.         if(self::$instance == null)
  8.             echo '<br/>','====1','<br/>';
  9.         else
  10.             echo '<br/>','====2','<br/>';
  11.     }

  12.     public static function getInstance(){
  13.         if(self::$instance == null){
  14.             self::$instance = new Singleton();
  15.             echo '<br/>','====3','<br/>';
  16.         }else
  17.             echo '<br/>','====4','<br/>';
  18.         return self::$instance;
  19.     }
  20. }

  21. $instance1 = Singleton::getInstance();
  22. ?>
复制代码
输出结果:
====0
====2
====3
请问为什么构造函数输出self:instance不为空,而getInstance()输出self:instance为空呢?
这种单例类还不能new对象,构造方法是怎么执行的呢?
百思不得其解,请高手帮忙解答,谢谢。

作者: brianzhuxd   发布时间: 2011-06-01

self:instance = &$this;
这句代码不就获得实例了嘛。

作者: Galenlong   发布时间: 2011-06-01