gzwrite
Description
Syntax
gzwrite( resource $stream, string $data, ?int $length = null ): int|false
Parameters
stream
The gz-file pointer. It must be valid, and must point to a file successfully opened by gzopen().
data
The string to write.
length
The number of uncompressed bytes to write. If supplied, writing will stop after length (uncompressed) bytes have been written or the end of data is reached, whichever comes first.
Return
Returns the number of (uncompressed) bytes written to the given gz-file stream, or false on failure.
Examples
1 · stream data
<? $filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/gz/1.gz"; $mode = "w"; $stream = gzopen($filename, $mode); if($stream === false) { die("gzopen"); } $data = "data"; $return = gzwrite($stream, $data); var_export($return); gzclose($stream); ?>
4
2 · length
<? $filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/gz/1.gz"; $mode = "w"; $stream = gzopen($filename, $mode); if($stream === false) { die("gzopen"); } $data = "data"; $length = 2; $return = gzwrite($stream, $data, $length); var_export($return); gzclose($stream); ?>
2