多例模式

 

 

 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

 

posted @ 2017-01-07 09:14  _logan  阅读(140)  评论(0编辑  收藏  举报