gzopen
Description
Syntax
gzopen( string $filename, string $mode, int $use_include_path = 0 ): resource|false
Parameters
filename
The file name.
mode
As in fopen() (rb or wb) but can also include a compression level (wb9) or a strategy: f for filtered data as in wb6f, h for Huffman only compression as in wb1h. (See the description of deflateInit2 in zlib.h for more information about the strategy parameter.)
use_include_path
Set to 1 to search for the file in the include_path also.
Return
Returns a file pointer to the file opened, after that, everything you read from this file descriptor will be transparently decompressed and what you write gets compressed.
If the open fails, the function returns false.
Examples
1 · filename mode
<? $filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/gz/1.gz"; $mode = "r"; $return = gzopen($filename, $mode); if($return === false) { die("gzopen"); } var_export($return); gzclose($return); ?>
NULL
2 · use_include_path · 0
<? $filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/gz/1.gz"; $mode = "r"; $use_include_path = 0; $return = gzopen($filename, $mode, $use_include_path); if($return === false) { die("gzopen"); } var_export($return); gzclose($return); ?>
NULL
3 · use_include_path · 1
<? $filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/gz/1.gz"; $mode = "r"; $use_include_path = 1; $return = gzopen($filename, $mode, $use_include_path); if($return === false) { die("gzopen"); } var_export($return); gzclose($return); ?>
NULL