\PhalApi_Response

Response Class

  • all of the reponse status, and format the result
  • 200 stands for success, while 400 stands for illegal request, and 500 stands for server internal error

Summary

Methods
Properties
Constants
setRet()
setData()
setMsg()
setDebug()
addHeaders()
output()
getResult()
getHeaders()
No public properties found
No constants found
handleHeaders()
formatResult()
$ret
$data
$msg
$headers
$debug
N/A
No private methods found
No private properties found
N/A

Properties

$ret

$ret : integer

Type

integer — reponse return code, 200 stands for success, while 400 stands for illegal request, and 500 stands for server internal error

$data

$data : array

Type

array — result wait to be send to client

$msg

$msg : string

Type

string — error message to return

$headers

$headers : array

Type

array — reponse headers

$debug

$debug : array

Type

array — debug infomation

Methods

setRet()

setRet(integer  $ret) : \PhalApi_Response

Set the response status

Parameters

integer $ret

response status, such as: 2xx, 4xx, 5xx

Returns

\PhalApi_Response

setData()

setData(\array/string  $data) : \PhalApi_Response

Set the response data

Parameters

\array/string $data

result data to client, we suggest return array data, not string data

Returns

\PhalApi_Response

setMsg()

setMsg(string  $msg) : \PhalApi_Response

Set the error message

Parameters

string $msg

error message

Returns

\PhalApi_Response

setDebug()

setDebug(string  $key, mixed  $value) : \PhalApi_Response

Set debug infomation

Parameters

string $key

debug key

mixed $value

debug data

Returns

\PhalApi_Response

addHeaders()

addHeaders(string  $key, string  $content) 

Add header

Parameters

string $key

header name

string $content

header content

output()

output() 

Ouput

getResult()

getResult() 

------------------ getter ------------------ *

getHeaders()

getHeaders(string  $key = NULL) : \string/array

Get Headers

Parameters

string $key

header name

Returns

\string/array —

return NULL when header not exists, and return all headers when $key is NULL

handleHeaders()

handleHeaders(  $headers) 

------------------ internal functions ------------------ *

Parameters

$headers

formatResult()

formatResult(array  $result) 

Format result data

Parameters

array $result

reponse data to client