![]() |
VOOZH | about |
final class Response implements IResponse
Mutable HTTP response for setting status code, headers, cookies, and redirects.
| $cookieDomain | The domain in which the cookie will be available |
| $cookiePath | The path in which the cookie will be available |
| $cookieSecure | Whether the cookie is available only through HTTPS |
| $warnOnBuffer | Whether to warn when there is data in the output buffer before sending headers |
| array<string,string> read-only | $headers |
No description
Returns HTTP response code.
Sends an HTTP header, replacing any previously sent header with the same name.
Adds an HTTP header without replacing a previously sent header with the same name.
Deletes a previously sent HTTP header.
Sends a Content-type HTTP header.
Triggers a browser download dialog for the response body with the given filename.
Redirects to another URL. Don't forget to quit the script then.
Sets the Cache-Control and Expires headers. Pass a time string (e.g. '20 minutes') to enable caching, or null to disable it entirely.
Checks whether HTTP headers have already been sent, making it impossible to modify them.
Returns the sent HTTP header, or null if it does not exist. The parameter is case-insensitive.
Returns all sent HTTP headers as associative array.
Sends a cookie.
Deletes a cookie.
__construct()
No description
IResponse
setCode(int $code, string|null $reason = null)
Sets HTTP response code.
| int | $code |
| string|null | $reason |
| IResponse |
| InvalidArgumentException |
| InvalidStateException |
int
getCode()
Returns HTTP response code.
| int |
IResponse
setHeader(string $name, string $value)
Sends an HTTP header, replacing any previously sent header with the same name.
IResponse
addHeader(string $name, string $value)
Adds an HTTP header without replacing a previously sent header with the same name.
self
deleteHeader(string $name)
Deletes a previously sent HTTP header.
| string | $name |
| self |
| InvalidStateException |
IResponse
setContentType(string $type, string|null $charset = null)
Sends a Content-type HTTP header.
| string | $type |
| string|null | $charset |
| IResponse |
| InvalidStateException |
Response
sendAsFile(string $fileName)
Triggers a browser download dialog for the response body with the given filename.
void
redirect(string $url, int $code = self::S302_Found)
Redirects to another URL. Don't forget to quit the script then.
| string | $url |
| int | $code |
| void |
| InvalidStateException |
IResponse
setExpiration(string|null $expire)
Sets the Cache-Control and Expires headers. Pass a time string (e.g. '20 minutes') to enable caching, or null to disable it entirely.
bool
isSent()
Checks whether HTTP headers have already been sent, making it impossible to modify them.
| bool |
string|null
getHeader(string $header)
Returns the sent HTTP header, or null if it does not exist. The parameter is case-insensitive.
| string | $header |
| string|null |
array
getHeaders()
Returns all sent HTTP headers as associative array.
| array |
IResponse
setCookie(string $name, string $value, string|int|DateTimeInterface|null $expire, string|null $path = null, string|null $domain = null, bool $secure = null, bool $httpOnly = true, SameSite $sameSite = SameSite::Lax, bool $partitioned = false)
Sends a cookie.
| string | $name |
| string | $value |
| string|int|DateTimeInterface|null | $expire |
| string|null | $path |
| string|null | $domain |
| bool | $secure |
| bool | $httpOnly |
| SameSite | $sameSite |
| bool | $partitioned |
| IResponse |
| InvalidStateException |
void
deleteCookie(string $name, string|null $path = null, string|null $domain = null, bool $secure = null)
Deletes a cookie.
| string | $name |
| string|null | $path |
| string|null | $domain |
| bool | $secure |
| void |
| InvalidStateException |