多例模式

 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
原文地址:https://www.cnblogs.com/hangtt/p/6258686.html