单态 1. [代码] 单态 ?phpclass A{private static $ob=null;private function __construct(){}public static function display(){if(self::$ob == null)return self::$ob = new A();elsereturn self::$ob;}}$a = A::display();$b = A::display();var_du
1. [代码]单态
<?php class A{ private static $ob=null; private function __construct(){} public static function display(){ if(self::$ob == null) return self::$ob = new A(); else return self::$ob; } } $a = A::display(); $b = A::display(); var_dump($a); var_dump($b);