当前位置: 移动技术网 > IT编程>开发语言>PHP > PHP对象实例化单例方法

PHP对象实例化单例方法

2017年12月12日  | 移动技术网IT编程  | 我要评论

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;
  }

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持移动技术网!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网