phpday 2027 - Call for Papers

The Yaf_Response_Abstract class

(Yaf >=1.0.0)

Introduction

Yaf_Response_Abstract is the base class of the response object, which carries the headers and the content blocks to be sent to the client. It is instantiated by Yaf_Dispatcher; use Yaf_Dispatcher::getResponse() to access it, typically inside controllers, actions or plugins.

The concrete subclasses are Yaf_Response_Http (used in web SAPIs, which actually sends HTTP headers) and Yaf_Response_Cli (used on the command line).

Class synopsis

class Yaf_Response_Abstract {
/* Constants */
const string DEFAULT_BODY = "content";
/* Properties */
protected $_header;
protected $_body;
protected $_sendheader;
/* Methods */
public function __construct()
public function appendBody(string $body, string $key = ?): Yaf_Response_Abstract|false|null
public function clearBody(string $key = ?): Yaf_Response_Abstract|false|null
public function getBody(string $key = ?): mixed
public function getHeader(string $name = ?): string|array|null
public function prependBody(string $body, string $key = ?): Yaf_Response_Abstract|false|null
public function response(): ?bool
public function setAllHeaders(array $headers): bool
public function setBody(string $body, string $key = ?): Yaf_Response_Abstract|false|null
public function setHeader(
    string $name,
    string $value,
    bool $replace = false,
    int $response_code = 0
): bool
public function setRedirect(string $url): ?bool
private function __toString(): string
}

Properties

_header

The HTTP headers set so far, as an array of header name/value pairs. Only meaningful for Yaf_Response_Http.

_body

The content blocks, keyed by the content key (by default content, i.e. Yaf_Response_Abstract::DEFAULT_BODY).

_sendheader

Whether headers should be sent together with the content. In Yaf_Response_Http it also tracks whether the headers have been sent already.

Table of Contents

User Contributed Notes

There are no user contributed notes for this page.
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top