Methods

Sets up the response with a body and a status code.

__construct(string $body, int $status, array $headers) 

Parameters

$body

string

The response body

$status

int

The response status

$headers

array

Returns the body as a string.

__toString() : string

Returns

string

Sets (or returns) the body for the response

body(string | bool $value) : \Fuel\Core\Response | string

Parameters

$value

stringbool

The response content

Returns

Creates an instance of the Response class

forge(string $body, int $status, array $headers) : \Fuel\Core\Response

Parameters

$body

string

The response body

$status

int

The HTTP response status for this response

$headers

array

Array of HTTP headers for this response

Returns

Gets header information from the queue

get_header(string $name) : mixed

Parameters

$name

string

The header name, or null for all headers

Returns

mixed

Redirects to another uri/url.

redirect(string $url, string $method, int $code) : void

Sets the redirect header, sends the headers and exits. Can redirect via a Location header or using a refresh header.

The refresh header works better on certain servers like IIS.

Parameters

$url

string

The url

$method

string

The redirect method

$code

int

The redirect status code

Redirects back to the previous page, if that page is within the current application.

redirect_back(string $url, string $method, int $code) : void

If not, it will redirect to the given url, and if none is given, back to the application root. If the current page is the application root, an exception is thrown

Parameters

$url

string

The url

$method

string

The redirect method

$code

int

The redirect status code

Exceptions

\RuntimeException If it would redirect back to itself

Sends the response to the output buffer.

send(bool $send_headers) : void

Optionally will send the headers.

Parameters

$send_headers

bool

Whether or not to send the defined HTTP headers

Sends the headers if they haven't already been sent.

send_headers() : bool

Returns whether they were sent or not.

Returns

bool

Adds a header to the queue

set_header(string $name, string $value, string | bool $replace) : \Fuel\Core\Response

Parameters

$name

string

The header name

$value

string

The header value

$replace

stringbool

Whether to replace existing value for the header, will never overwrite/be overwritten when false

Returns

Adds multiple headers to the queue

set_headers(array $headers, string | bool $replace) : \Fuel\Core\Response

Parameters

$headers

array

Assoc array with header name / value combinations

$replace

stringbool

Whether to replace existing value for the header, will never overwrite/be overwritten when false

Returns

Sets the response status code

set_status(int $status) : \Fuel\Core\Response

Parameters

$status

int

The status code

Returns

 Properties

 

<p>The content of the response</p>

$body : string

 

<p>An array of HTTP headers</p>

$headers : array

 

<p>The HTTP status code</p>

$status : int

 

<p>An array of status codes and messages See http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml for the complete and approved list, and links to the RFC's that define them</p>

$statuses : array