Stream::read( $length )

In this article

Source

public function read($length): string
{
    if (!isset($this->stream)) {
        throw new \RuntimeException('Stream is detached');
    }
    if (!$this->readable) {
        throw new \RuntimeException('Cannot read from non-readable stream');
    }
    if (\false === $result = @\fread($this->stream, $length)) {
        throw new \RuntimeException('Unable to read from stream: ' . (\error_get_last()['message'] ?? ''));
    }
    return $result;
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.