PHP 8.6.0 Beta 3 is available for testing

Yaf_Response_Abstract::getBody

(Yaf >=1.0.0)

Yaf_Response_Abstract::getBodyRetrieve a response body block

Beschreibung

public function Yaf_Response_Abstract::getBody(string $key = ?): mixed

Retrieve the content of a response body block.

Parameter-Liste

key

The content key. If not specified, the DEFAULT_BODY block is used; pass null to get all content blocks as an array.

Rückgabewerte

The content string, or an array of all content blocks when key is null. Returns an empty string if the block is not set.

Beispiele

Beispiel #1 Yaf_Response_Abstract::getBody() example

<?php
$response = new Yaf_Response_Http();

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

var_dump($response->getBody());
var_dump($response->getBody(Yaf_Response_Abstract::DEFAULT_BODY));
var_dump($response->getBody("footer"));
var_dump($response->getBody(NULL));
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

string(5) "Hello"
string(5) "Hello"
string(6) " World"
array(2) {
  ["content"]=>
  string(5) "Hello"
  ["footer"]=>
  string(6) " World"
}

Siehe auch

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top