PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Wojciech Sznapka's Blog: Power of PHP streams - decompress gz archives on the fly from remote server

Note: This article was originally published at PHPDeveloper on 25 November 2010.
PHPDeveloper

Wojciech Sznapka has a new post to his blog today looking at the "power of PHP streams" and how they can be used to decompress gzipped data from remote servers.

Probably most of us heard about streams in PHP. They are background of all files and network operations in PHP, even if we don't see it. Everytime when you use file_get_contents or fopen you are actually using streams. But there are many stream wrappers I haven't used, because they aren't well known.One of them is compress.zlib (and two other compression stream filters).

He includes a quick example (because, thankfully, that's all working with streams like this usually requires) about pulling in a file from his server and uses the stream to fetch and unzip the data to display the contents.