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