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 }
php 设计模式学习笔记之单例模式
原文地址:http://www.cnblogs.com/yin5th/p/7609283.html