首页 > 代码库 > php单例设计模式

php单例设计模式

class car {	static $obj = null;	private function __construct(){}	static function getObj(){		if(is_null(self::$obj)){			self::$obj = new car;		}		return self::$obj;	}	function __destruct(){		echo "********************<br>";	}	function say(){		echo ‘Hello World!<br>‘;	}}$c = car::getObj();$d = car::getObj();$e = car::getObj();$f = car::getObj();$c = car::getObj();$c->say();$f->say();

  

php单例设计模式