php 设计模式学习笔记之单例模式

 1 // 单利模式(三私一公)
 2 
 3 class Singleton{
 4 
 5     //私有化构造方法,禁止外部实例化
 6 
 7     private function __construct(){}
 8 
 9     //私有化__clone,防止被克隆
10 
11     private function __clone(){}
12 
13     //私有化内部实例化的对象
14 
15     private static $instance = null;
16 
17     // 公有静态实例方法
18 
19     public static function getInstance(){
20 
21       // ...
22 
23     }
24 
25 }
原文地址:https://www.cnblogs.com/yin5th/p/7609283.html