Link to home
Create AccountLog in
Avatar of itudor
itudorFlag for Romania

asked on

How to gzdecode PHP 5


How to decode GZIP content ? There is a function gzdecode() but it only appears in PHP6. I tried several functions that are listed on but none did the work properly with larger file.

Are there any solution that work on both linux and windows OS using PHP ?

Thank you
Avatar of edbonl

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of itudor


The content that needs to be  gzdecode comes from a cURL request. So a webpage may or may not be gzipped so your solution which I haven't tested may work but it lacks the integration manner with direct stream from a variable.

However I have come up to this workaround in cURL:
curl_setopt($hd, CURLOPT_ENCODING , 'gzip');

Open in new window

So I have found the solution but yours may very well work as a last resort method. Or in case you're not working with cURL your solution will probably function with streams.