写一个简单是单例模式的例子
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 |
class Pattern{ Private $array = array (); private
Static $instance ; Private function
__construct(){ } public
static function getInstance(){ if ( empty (self:: $instance )){ self:: $instance = new
Pattern(); } return
self:: $instance ; } public
function setArray( $key , $value ){ $this -> array [ $key ]= $value ; } public
function getArray( $key ){ return
$this -> array [ $key ]; } } |
原文:http://www.cnblogs.com/xiashuo-he/p/3627801.html