class Response implements IResponse

HttpResponse class.

Properties

string $cookieDomain
string $cookiePath
bool $cookieSecure
bool $cookieHttpOnly
bool $warnOnBuffer
array read-only $headers

Methods

__construct()

No description

setCode($code, $reason = null)

Sets HTTP response code.

int
getCode()

Returns HTTP response code.

setHeader($name, $value)

Sends a HTTP header and replaces a previous one.

addHeader($name, $value)

Adds HTTP header.

setContentType($type, $charset = null)

Sends a Content-type HTTP header.

void
redirect($url, $code = self::S302_FOUND)

Redirects to a new URL. Note: call exit() after it.

setExpiration($time)

Sets the number of seconds before a page cached on a browser expires.

bool
isSent()

Checks if headers have been sent.

string|null
getHeader($header, $default = null)

Returns value of an HTTP header.

array
getHeaders()

Returns a list of headers to sent.

static 
date($time = null) deprecated

No description

__destruct()

No description

setCookie($name, $value, $time, $path = null, $domain = null, $secure = null, $httpOnly = null, $sameSite = null)

Sends a cookie.

void
deleteCookie($name, $path = null, $domain = null, $secure = null)

Deletes a cookie.

Details

at line 45
__construct()

No description

at line 61
IResponse setCode($code, $reason = null)

Sets HTTP response code.

Parameters

$code
$reason

Return Value

IResponse

Exceptions

InvalidArgumentException
InvalidStateException

at line 91
int getCode()

Returns HTTP response code.

Return Value

int

at line 104
IResponse setHeader($name, $value)

Sends a HTTP header and replaces a previous one.

Parameters

$name
$value

Return Value

IResponse

Exceptions

InvalidStateException

at line 125
IResponse addHeader($name, $value)

Adds HTTP header.

Parameters

$name
$value

Return Value

IResponse

Exceptions

InvalidStateException

at line 140
IResponse setContentType($type, $charset = null)

Sends a Content-type HTTP header.

Parameters

$type
$charset

Return Value

IResponse

Exceptions

InvalidStateException

at line 154
void redirect($url, $code = self::S302_FOUND)

Redirects to a new URL. Note: call exit() after it.

Parameters

$url
$code

Return Value

void

Exceptions

InvalidStateException

at line 171
IResponse setExpiration($time)

Sets the number of seconds before a page cached on a browser expires.

Parameters

$time

Return Value

IResponse

Exceptions

InvalidStateException

at line 191
bool isSent()

Checks if headers have been sent.

Return Value

bool

at line 203
string|null getHeader($header, $default = null)

Returns value of an HTTP header.

Parameters

$header
$default

Return Value

string|null

at line 220
array getHeaders()

Returns a list of headers to sent.

Return Value

array

(name => value)

at line 234
static date($time = null) deprecated

deprecated

No description

Parameters

$time

at line 241
__destruct()

No description

at line 269
IResponse setCookie($name, $value, $time, $path = null, $domain = null, $secure = null, $httpOnly = null, $sameSite = null)

Sends a cookie.

Parameters

$name
$value
$time
$path
$domain
$secure
$httpOnly
$sameSite

Return Value

IResponse

Exceptions

InvalidStateException

at line 306
void deleteCookie($name, $path = null, $domain = null, $secure = null)

Deletes a cookie.

Parameters

$name
$path
$domain
$secure

Return Value

void

Exceptions

InvalidStateException

Traits

SmartObject