通过PHP解压缩.gz文件 [英] Decompressing a .gz file via PHP

查看:265
本文介绍了通过PHP解压缩.gz文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够通过PHP解压一些我使用 gzip 格式的字符串中的数据。我需要通过PHP,而不是通过调用 - 通过 system 例如 - 外部程序。

I need to be able to decompress through PHP some data that I have in a string which uses the gzip format. I need to do this via PHP, not by calling - through system for example - an external program.

请参阅文档,并找到 gzdecode 。太糟糕了,它不存在。进一步通过google它似乎这个功能是实现在PHP6,我不能使用。 (有趣的是 gzencode 存在并且正在工作)。

I go to the documentation and I find gzdecode. Too bad it doesn't exist. Digging further through google it appears this function was implemented in PHP6, which I cannot use. (Interestingly enough gzencode exists and is working).

我相信 - 但我不确定 - gzip 格式只是有一些额外的标题数据。有没有办法解压缩它通过操纵这些额外的数据,然后使用 gzuncompress 或一些其他方式?

I believe - but I'm not sure - that the gzip format simply has some extra header data. Is there a way to uncompress it by manipulating this extra data and then using gzuncompress, or some other way?

感谢

推荐答案

gzdecode()但您可以使用升级版的实现。它真的只是一些额外的标题字节。

gzdecode() is not yet in PHP. But you can use the implementation from upgradephp. It really is just a few extra header bytes.

另一个选择是使用gzopen。也许就像 gzopen(data:app / bin,....)甚至。

Another option would be to use gzopen. Maybe just like gzopen("data:app/bin,....") even.

这篇关于通过PHP解压缩.gz文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆