1 | <?php |
||
9 | class CResponseBasic |
||
10 | { |
||
11 | |||
12 | |||
13 | /** |
||
14 | * Properties |
||
15 | * |
||
16 | */ |
||
17 | private $headers; // Set all headers to send |
||
18 | |||
19 | |||
20 | |||
21 | /** |
||
22 | * Set headers. |
||
23 | * |
||
24 | * @param string $header type of header to set |
||
25 | * |
||
26 | * @return $this |
||
27 | */ |
||
28 | public function setHeader($header) |
||
32 | |||
33 | |||
34 | |||
35 | /** |
||
36 | * Check if headers are already sent and throw exception if it is. |
||
37 | * |
||
38 | * @return void |
||
39 | * |
||
40 | * @throws \Exception |
||
41 | */ |
||
42 | public function checkIfHeadersAlreadySent() |
||
48 | |||
49 | |||
50 | |||
51 | /** |
||
52 | * Send headers. |
||
53 | * |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function sendHeaders() |
||
85 | |||
86 | |||
87 | |||
88 | /** |
||
89 | * Redirect to another page. |
||
90 | * |
||
91 | * @param string $url to redirect to |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | public function redirect($url) |
||
102 | } |
||
103 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.