Zend Framework
3.0
|
JSON response. More...
Public Member Functions | |
__construct ($data, $status=200, array $headers=[], $encodingOptions=self::DEFAULT_JSON_FLAGS) | |
Create a JSON response with the given data. | |
Public Member Functions inherited from Response | |
__construct ($body= 'php://memory', $status=200, array $headers=[]) | |
getStatusCode () | |
{} | |
getReasonPhrase () | |
{} | |
withStatus ($code, $reasonPhrase= '') | |
{} | |
Public Attributes | |
const | DEFAULT_JSON_FLAGS = 79 |
Default flags for json_encode; value of: | |
JSON response.
Allows creating a response by passing data to the constructor; by default, serializes the data to JSON, sets a status code of 200 and sets the Content-Type header to application/json.
__construct | ( | $data, | |
$status = 200 , |
|||
array | $headers = [] , |
||
$encodingOptions = self::DEFAULT_JSON_FLAGS |
|||
) |
Create a JSON response with the given data.
Default JSON encoding is performed with the following options, which produces RFC4627-compliant JSON, capable of embedding into HTML.
mixed | $data | Data to convert to JSON. |
int | $status | Integer status code for the response; 200 by default. |
array | $headers | Array of headers to use at initialization. |
int | $encodingOptions | JSON encoding options to use. |
InvalidArgumentException | if unable to encode the $data to JSON. |
const DEFAULT_JSON_FLAGS = 79 |
Default flags for json_encode; value of:
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_UNESCAPED_SLASHES
int