1: | <?php |
2: | |
3: | namespace ngatngay; |
4: | |
5: | use ngatngay\http\request; |
6: | use ngatngay\http\response; |
7: | |
8: | function request(): request |
9: | { |
10: | static $instance = null; |
11: | |
12: | if ($instance === null) { |
13: | $instance = new request(); |
14: | } |
15: | |
16: | return $instance; |
17: | } |
18: | |
19: | function response($data = null, $status = 200, $headers = []): response |
20: | { |
21: | return new response($data, $status, $headers); |
22: | } |
23: | |
24: | function redirect(string $url, int $status = 301) |
25: | { |
26: | ob_end_clean(); |
27: | http_response_code($status); |
28: | header('Location: ' . $url); |
29: | exit; |
30: | } |
31: | |
32: | function refresh() |
33: | { |
34: | ob_end_clean(); |
35: | header('Refresh:0'); |
36: | exit; |
37: | } |
38: | |