-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
37 lines (27 loc) · 864 Bytes
/
index.php
File metadata and controls
37 lines (27 loc) · 864 Bytes
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
<?php
class MyGreeter{
protected $time;
protected $greetingMessageMap;
public function __construct()
{
$this->greetingMessageMap = [
11 => '早上好',
17 => '下午好',
23 => '下午好',
];
}
public function greetingMessage(){
$now = time();
foreach ($this->greetingMessageMap as $k => $v){
$tmpTime = mktime($k, 59, 59);
if ($tmpTime >= $now){
return $v;
}
}
}
}
$greetingMessage = (new MyGreeter()) -> greetingMessage();
var_dump($greetingMessage);
// 是否需要自主传入时间, 传入什么格式?
// 是否需要根据不同用户返回不同语言的问候语?(中文,日文,英文等)
// 是否有时区的判断