gzopen() также можно использовать для несжатых
файлов (т.е. не в формате gzip); в этом случае gzread()
вернёт файл напрямую, без какой-либо обработки.
Список параметров
filename
Имя файла.
mode
К в fopen() (rb или
wb), но также может включать уровень сжатия
(wb9) или стратегию: f для
фильтрации данных как в wb6f, h
для Huffman only compression как в wb1h
(см. описание deflateInit2 в zlib.h).
use_include_path
Если вы хотите, чтобы файл также искался в директориях
include_path, установите
значение этого аргумента в 1.
Возвращаемые значения
Возвращает указатель на открытый файл, после чего всё, что вы читаете из
этого дескриптора, будет автоматически распаковываться, а всё, что вы
записываете - упаковываться.
dtorop932 at hotmail dot com's comments, according to my tests, is incorrect. That code wishes to download the entire file before parsing, which is inconvinient. The wget method works though.
"On the fly" gunzipping actually DOES seem to work - it just appears that only LOCAL streams/files (including php://stdin) can be accessed for some reason. I THINK (but have not yet tested) that you could similarly gzopen "php://stdout" and pass a stream of gzipped data to the browser (when run from a web page) or console (when run standalone) through there.
where gunzip_stuff.php would be a script that gzopened "php://stdin" and did gzgets from that stream, and it seems to work fine, but that obviously doesn't help someone wanting to grab gzipped streams from remote sites from a web-based script.
Being able to read gzip streams from ftp and http is near the top of my personal wishlist at the moment...