摘要:
//单例模式 /** 2 * 设计模式之单例模式 3 * $_instance必须声明为静态的私有变量 4 * 构造函数必须声明为私有,防止外部程序new类从而失去单例模式的意义 5 * getInstance()方法必须设置为公有的,必须调用此方法以返回实例的一个引用 6 * ::操作符只能访问静 阅读全文
摘要:
//工厂化模式class Factory {//创建一个基本的工厂类 static public function fac($id){//创建一个返回对象实例的静态方法 if(1 == $id) return new A(); elseif(2==$id) return new B(); elsei 阅读全文
摘要:
/** * 观察者模式 * @author: Fantasy * @date: 2017/02/17 */ /** * 事件产生类 * Class EventGenerator */abstract class EventGenerator{ private $ObServers = []; //增 阅读全文