Skip to content

Stream: read Example

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

Shieldon\Psr7\Stream

read($length)

Read data from the stream.

  • param int length * Read up to $length bytes from the object and return them.
  • return string

Example:

$stream = new Stream(fopen('php://temp', 'r+'));
$stream->write('Glory to Hong Kong');

echo $stream->read(5);

// Outputs: Glory
Clone this wiki locally