PHP 클래스 Zend\Diactoros\Response\JsonResponse

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.
상속: extends Zend\Diactoros\Response, use trait InjectContentTypeTrait
파일 보기 프로젝트 열기: zendframework/zend-diactoros 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( mixed $data, integer $status = 200, array $headers = [], integer $encodingOptions = self::DEFAULT_JSON_FLAGS ) Create a JSON response with the given data.

비공개 메소드들

메소드 설명
jsonEncode ( mixed $data, integer $encodingOptions ) : string Encode the provided data to JSON.

메소드 상세

__construct() 공개 메소드

Default JSON encoding is performed with the following options, which produces RFC4627-compliant JSON, capable of embedding into HTML. - JSON_HEX_TAG - JSON_HEX_APOS - JSON_HEX_AMP - JSON_HEX_QUOT - JSON_UNESCAPED_SLASHES
public __construct ( mixed $data, integer $status = 200, array $headers = [], integer $encodingOptions = self::DEFAULT_JSON_FLAGS )
$data mixed Data to convert to JSON.
$status integer Integer status code for the response; 200 by default.
$headers array Array of headers to use at initialization.
$encodingOptions integer JSON encoding options to use.