首页 > 其他 > 详细

多例模式

时间:2017-01-07 09:59:56      阅读:199      评论:0      收藏:0      [点我收藏+]

 

技术分享

 

技术分享
 1 <?php
 2 
 3 class Multiton
 4 {
 5     private static $conn = [];
 6 
 7     private function __construct()
 8     {
 9 
10     }
11 
12     private function __clone()
13     {
14 
15     }
16 
17     private function __wakeup()
18     {
19 
20     }
21 
22     public static function getConn($type)
23     {
24         if (!array_key_exists($type, self::$conn)) {
25             self::$conn[$type] = new self();
26         }
27 
28         return self::$conn[$type];
29     }
30 }
View Code

 

多例模式

原文:http://www.cnblogs.com/hangtt/p/6258686.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!