Skip to content

Message: withBody Example

Terry L edited this page Jun 20, 2020 · 3 revisions

Shieldon\Psr7\Message

withBody($body)

Return an instance with the specified message body.

  • param StreamInterface body * Body.
  • return static

Example:

$stream = new \Shieldon\Psr7\Stream(fopen('php://temp', 'r+'));
$stream->write('Foo Bar');

$message = $message->withBody($stream);

echo $message->getBody()->getContents();

// Outputs: Foo Bar
Clone this wiki locally