Response
    
            
            in package
            
        
    
    
    
A class to encapsulate a HTTP Response.
Tags
Table of Contents
Properties
- $body : string
- The body of the response.
- $cookies : array<string|int, mixed>
- An associative array of HTTP cookies on this response.
- $headers : array<string|int, mixed>
- An associative array of headers for the response.
- $HTTPStatusCodes : array<string|int, mixed>
- Array of supported HTTP response codes.
- $status : int
- The status code of the response.
Methods
- __construct() : mixed
- Build the response.
- getBody() : string|null
- Get the response body.
- getContentLength() : int
- Get the content length of the response.
- getCookie() : mixed
- Get the cookie matching the key provided.
- getCookies() : array<string|int, mixed>
- Get all of the cookies for the response.
- getHeader() : mixed
- Get the header matching the key provided.
- getHeaders() : array<string|int, mixed>
- Get all of the headers for the response.
- getStatus() : int
- Get the status code of the response.
- getStatusMessage() : string
- Get the status message of the response.
- redirect() : void
- Builds a redirect response.
- send() : void
- Sends the current response to standard output before exiting the current process.
- setBody() : void
- Set the response body.
- setCookie() : void
- Set a cookie key/value tuple for the response.
- setHeader() : void
- Set a header key/value tuple for the response.
- setStatus() : void
- Set the status code of the response.
Properties
$body
The body of the response.
    private
        string
    $body
    
    
    
    
    Tags
$cookies
An associative array of HTTP cookies on this response.
    private
        array<string|int, mixed>
    $cookies
    
    
    
    
    Tags
$headers
An associative array of headers for the response.
    private
        array<string|int, mixed>
    $headers
    
    
    
    
    Tags
$HTTPStatusCodes
Array of supported HTTP response codes.
    private
        array<string|int, mixed>
    $HTTPStatusCodes
     = array(100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Unordered Collection', 426 => 'Upgrade Required', 449 => 'Retry With', 450 => 'Blocked by Windows Parental Controls', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 509 => 'Bandwidth Limit Exceeded', 510 => 'Not Extended')
    
    
    
    Tags
$status
The status code of the response.
    private
        int
    $status
    
    
    
    
    Tags
Methods
__construct()
Build the response.
    public
                    __construct(int $status[, string $body = null ][, array<string|int, mixed> $headers = array() ]) : mixed
    Parameters
- $status : int
- 
                    The HTTP status code of the response. 
- $body : string = null
- 
                    The body of the response (optional). 
- $headers : array<string|int, mixed> = array()
- 
                    The headers to set on the response (optional). 
Tags
getBody()
Get the response body.
    public
                    getBody() : string|null
    Tags
Return values
string|nullgetContentLength()
Get the content length of the response.
    public
                    getContentLength() : int
    Tags
Return values
intgetCookie()
Get the cookie matching the key provided.
    public
                    getCookie(string $key[, mixed $default = null ]) : mixed
    Parameters
- $key : string
- 
                    The key to search for 
- $default : mixed = null
- 
                    If key is not found, return this instead 
Tags
getCookies()
Get all of the cookies for the response.
    public
                    getCookies() : array<string|int, mixed>
    Tags
Return values
array<string|int, mixed>getHeader()
Get the header matching the key provided.
    public
                    getHeader(string $key[, mixed $default = null ]) : mixed
    Parameters
- $key : string
- 
                    The key to search for 
- $default : mixed = null
- 
                    If key is not found, return this instead 
Tags
getHeaders()
Get all of the headers for the response.
    public
                    getHeaders() : array<string|int, mixed>
    Tags
Return values
array<string|int, mixed>getStatus()
Get the status code of the response.
    public
                    getStatus() : int
    Tags
Return values
intgetStatusMessage()
Get the status message of the response.
    public
                    getStatusMessage() : string
    Return values
stringredirect()
Builds a redirect response.
    public
                    redirect(string $URL) : void
    Parameters
- $URL : string
- 
                    The URL to redirect the client to. 
Tags
send()
Sends the current response to standard output before exiting the current process.
    public
                    send() : void
    Tags
setBody()
Set the response body.
    public
                    setBody(string $body) : void
    Parameters
- $body : string
- 
                    The response body. 
Tags
setCookie()
Set a cookie key/value tuple for the response.
    public
                    setCookie(string $cookie, string $value) : void
    Parameters
- $cookie : string
- 
                    The cookie key name. 
- $value : string
- 
                    The cookie value. 
Tags
setHeader()
Set a header key/value tuple for the response.
    public
                    setHeader(string $header, string $value) : void
    Parameters
- $header : string
- 
                    The header key name. 
- $value : string
- 
                    The header value. 
Tags
setStatus()
Set the status code of the response.
    public
                    setStatus(int $status) : void
    Parameters
- $status : int
- 
                    The response code.