PHP对象实例化单例方法

本文主要介绍了PHP实例化对象单例的方法,具有很好的参考价值,下面跟着小编一起来看下吧

PHP实例化对象单例的方法:

三私一公:2个私有方法,1个私有属性,1个公共方法

   private function __construct(){} //不可以继承构造方法   private function __clone(){}//不可以继承克隆方法   privare static $_instance; 

一公 

 public static function getinstance(){     if(!isset(static:$_instance)){       static::$_instance=new static();       }       return static::$_instance;   } 

以上就是PHP对象实例化单例方法的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » PHP编程