class siagle{ public $hash = ''; static protected $ins = NULL; final protected function __construct(){ $this->hash = mt_rand(1,9999); } static public function getInstence(){ if (self::$ins instanceof self){ return self::$ins; } self::$ins = new self(); return self::$ins; } } $s1 = siagle::getInstence(); $s2 = siagle::getInstence(); echo $s1 == $s2 ? '相等':'不相等';