php8.5
Home/ Manual/ yaf / yaf_response_abstract/ Yaf_Response_Abstract::__toString

Yaf_Response_Abstract::__toString

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Retrieve all bodys as string

Description

Yaf_Response_Abstract::__toString(): string

Returns all body blocks of the response, concatenated into a single string in the order in which they were added. This is what is output when a response object is used in a string context.

Parameters Parameters

Return Values

The response body as a string.

Examples

Yaf_Response_Abstract::__toString example

php
<?php
$response = new Yaf_Response_Http();

$response->setBody("Hello")->setBody(" World", "footer");

/* using the response in a string context renders all body blocks */
echo $response;
var_dump((string) $response);
?>

The above example will output something similar to:

output
Hello World
string(11) "Hello World"

See Also

  • Yaf_Response_Abstract::getBody
  • Yaf_Response_Abstract::setBody
  • Yaf_Response_Abstract::response

Source: reference/yaf/yaf_response_abstract/tostring.xml · from the official PHP manual (php/doc-en)