thinkphp5.1中的单例模式

原创 2019-04-16 20:33:31 465
摘要://thinkphp5.1中的单例模式class Demo{    private function __construct(){}    private function __clone(){}    protected static $instance=null; 

//thinkphp5.1中的单例模式

class Demo

{

    private function __construct(){}

    private function __clone(){}

    protected static $instance=null;

    public static function getConnect(){

       if(is_null(static::$instance)){

           static::$instance=new static();

         }

        return static::$instance;

     }

}

$connect=Demo::getConnect();

批改老师:查无此人批改时间:2019-04-17 09:17:34
老师总结:完成的不错。写代码要多写点注释,才方便别人查看。继续加油。

发布手记

热门词条