PHP 8.1.28 Released!

Yaf_Response_Abstract::getBody

(Yaf >=1.0.0)

Yaf_Response_Abstract::getBodyコンテンツを取得する

説明

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

コンテンツを取得します。

パラメータ

key

コンテンツのキー。キーを指定しない場合は、Yaf_Response_Abstract::DEFAULT_BODY を使います。null を渡すと、すべてのコンテンツを配列で返します。 as a array

注意:

このパラメータは 2.2.0 で導入されました。

戻り値

例1 Yaf_Response_Abstract::getBody() の例

<?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)); // すべてを取得
?>

上の例の出力は、 たとえば以下のようになります。

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

参考

add a note

User Contributed Notes

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