Skip to content

Instantly share code, notes, and snippets.

@sasezaki
Last active October 20, 2015 13:53
Show Gist options
  • Save sasezaki/33875978610a508c6f5f to your computer and use it in GitHub Desktop.
Save sasezaki/33875978610a508c6f5f to your computer and use it in GitHub Desktop.
<?php
use Zend\Diactoros\Response;
require_once __DIR__.'/vendor/autoload.php';
$res = new Response();
$res->getBody()->write('hello');
$contents = $res->getBody()->getContents();
var_dump($contents); // ""
$res->getBody()->seek(0);
$contents = $res->getBody()->getContents();
var_dump($contents); // "hello"
$res->getBody()->seek(0);
$contents = $res->getBody()->getContents();
var_dump($contents); // "hello"
$res->getBody()->seek(2);
$contents = $res->getBody();
var_dump((string)$contents); // "hello"
$contents = $res->getBody()->getContents();
var_dump($contents); // ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment