Stream::write( $string )

Source

public function write($string): int
{
    if (!isset($this->stream)) {
        throw new \RuntimeException('Stream is detached');
    }
    if (!$this->writable) {
        throw new \RuntimeException('Cannot write to a non-writable stream');
    }
    // We can't know the size after writing anything
    $this->size = null;
    if (\false === $result = @\fwrite($this->stream, $string)) {
        throw new \RuntimeException('Unable to write to stream: ' . (\error_get_last()['message'] ?? ''));
    }
    return $result;
}

User Contributed Notes

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