-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResponse.php
45 lines (29 loc) · 895 Bytes
/
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
<?php
// below functions shall encapsulated in Class.
$response = array();
//Response
function setResponse($key, $value) {
$this->response[$key] = $value;
}
//Success Response
function successResponse($response_code = null) {
//Set Success Status
$this->response['return_code'] = 1;
$this->response['return_value'] = 'ok';
//Response Code Success
if (!is_null($response_code))
$this->response['error_code'] = $response_code;
die(json_encode($this->response));
}
//Error Response
function errorResponse($response_msg = '', $response_code = null) {
//Error Status
$this->response['return_code'] = 0;
//Error Code
if (!is_null($response_code))
$this->response['error_code'] = $response_code;
//Response Message
if ($response_msg !== '')
$this->response['return_value'] = $response_msg;
die(json_encode($this->_response));
}