标签:blank 简单工厂 功能 tar new http inf 创建 code
<?php // 自动加载 spl_autoload_register(function ($class) { $file = __DIR__ . ‘/‘ . $class . ‘.php‘; require_once($file); }); $mode = Cache::cacheMode(); $mode->getName();
公共缓存文件 Cache.php
<?php /** * 缓存公共方法 **/ class Cache { public static function cacheMode() { return new MemcachedMode(); } }
Redis类:RedisMode.php
<?php class RedisMode { public function getName() { echo ‘我是Redis‘; } }
Memcached类:MemcachedMode.php
<?php class MemcachedMode { public function getName() { echo ‘我是Memcached‘; } }
/GongChang
GitHub源码地址:https://github.com/xiaobaoword/design_pattern/tree/master/GongChang
标签:blank 简单工厂 功能 tar new http inf 创建 code
原文地址:https://www.cnblogs.com/houdabao/p/9517820.html