-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdanli.php
47 lines (37 loc) · 854 Bytes
/
danli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
//2018年12月5日14:27:05
//单例模式
class danli{
private $value = array();
private static $instance;
public static function getInstance()
{
if(!(self::$instance)){
self::$instance = new danli();
}
return self::$instance;
}
private function __construct()
{
}
public function __clone()
{
// TODO: Implement __clone() method.
}
public function __wakeup()
{
// TODO: Implement __wakeup() method.
}
public function setValue($key,$val){
$this->value[$key] = $val;
}
public function getValue($key){
return $this->value[$key];
}
}
$danli = danli::getInstance();
$danli->setValue('name','白色彩虹');
unset($danli);
var_dump($danli);
$danli2 = danli::getInstance();
print $danli2->getValue('name');