摘要:<?php final class Test { private static $instance = null; private function __construct() { return 'is ok'; } private function&n
<?php
final class Test
{
	private static $instance = null;
	private function __construct()
	{
		return 'is ok';
	}
	private function __clone(){}
	public static function getSingleton()
	{
		if(is_null(self::$instance))
		{
			self::$instance = new self();
		}
		return self::$instance;
	}
}
$test = test::getSingleton();
$test1 = test::getSingleton();
var_dump($test);
var_dump($test1);php单例模式案例
						批改老师:天蓬老师批改时间:2019-01-01 19:51:15		
						
老师总结:任何一种语言,都会有一个单例模式, 非常重要,也很常用,一定要记住					
 
                 
 
 
  
            