forked from calinrada/php-apidoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResponse.php
55 lines (51 loc) · 1.13 KB
/
Response.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
48
49
50
51
52
53
54
55
<?php
/**
* This file is part of the php-apidoc package.
*/
namespace Crada\Apidoc;
/**
* @license http://opensource.org/licenses/bsd-license.php The BSD License
* @author Calin Rada <[email protected]>
*/
class Response
{
/**
* Set header
*
* @param string $key
* @param string $value
* @param integer $http_response_code Optional
* @example $response->setHeader('Content-type','application/json')
*/
public function setHeader($key, $value, $http_response_code = null)
{
header($key.': '.$value, null, $http_response_code);
}
/**
* Set content type for the output
*
* @param string $s_contentType
* @see http://www.freeformatter.com/mime-types-list.html
*/
public function setContentType($s_contentType)
{
header('Content-type: '.$s_contentType);
}
/**
* Sends connection: close header
*/
public function closeConection()
{
header('Connection: close');
}
/**
* Wraper for echo
*
* @param $data
*/
public function send($data)
{
echo $data;
exit(0);
}
}