You are here

public function Stream::read in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/zendframework/zend-diactoros/src/Stream.php \Zend\Diactoros\Stream::read()
  2. 8.0 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::read()
  3. 8.0 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Stream::read()
Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::read()

Read data from the stream.

Parameters

int $length Read up to $length bytes from the object and return: them. Fewer than $length bytes may be returned if underlying stream call returns fewer bytes.

Return value

string Returns the data read from the stream, or an empty string if no bytes are available.

Throws

\RuntimeException if an error occurs.

Overrides StreamInterface::read

File

vendor/guzzlehttp/psr7/src/Stream.php, line 205

Class

Stream
PHP stream implementation.

Namespace

GuzzleHttp\Psr7

Code

public function read($length) {
  if (!$this->readable) {
    throw new \RuntimeException('Cannot read from non-readable stream');
  }
  return fread($this->stream, $length);
}