Response
in package
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- The headers array is a set of key/value pairs. If a header is present multiple times then the value is an array of all the values.
- __toString() : string
- Converts the response object to string containing all headers and the response content.
- getContent() : string
- Gets the response content.
- getHeader() : string|array<string|int, mixed>
- Gets a response header.
- getHeaders() : array<string|int, mixed>
- Gets the response headers.
- getStatus() : int
- Gets the response status code.
- buildHeader() : string
- Returns the build header line.
Properties
$content
protected
mixed
$content
$headers
protected
mixed
$headers
$status
protected
mixed
$status
Methods
__construct()
The headers array is a set of key/value pairs. If a header is present multiple times then the value is an array of all the values.
public
__construct([string $content = '' ][, int $status = 200 ][, array<string|int, mixed> $headers = [] ]) : mixed
Parameters
- $content : string = ''
-
The content of the response
- $status : int = 200
-
The response status code
- $headers : array<string|int, mixed> = []
-
An array of headers
__toString()
Converts the response object to string containing all headers and the response content.
public
__toString() : string
Return values
string —The response with headers and content
getContent()
Gets the response content.
public
getContent() : string
Return values
string —The response content
getHeader()
Gets a response header.
public
getHeader(string $header[, bool $first = true ]) : string|array<string|int, mixed>
Parameters
- $header : string
-
The header name
- $first : bool = true
-
Whether to return the first value or all header values
Return values
string|array<string|int, mixed> —The first header value if $first is true, an array of values otherwise
getHeaders()
Gets the response headers.
public
getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed> —The response headers
getStatus()
Gets the response status code.
public
getStatus() : int
Return values
int —The response status code
buildHeader()
Returns the build header line.
protected
buildHeader(string $name, string $value) : string
Parameters
- $name : string
-
The header name
- $value : string
-
The header value
Return values
string —The built header line