开发者

Any Library/Class To Decode/Encode Gzip, compress, x-gzip or x-compress? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 8 years ago.

Improve this question

Any Php Cl开发者_如何学JAVAass To Decode/Incode Strings with Gzip, compress, x-gzip or x-compress Algorithm .

Thanks


See in the manual: PHP: Compression and Archive functions

and there specifically: ZLib functions, e.g. gzcompress()

They require the ZLib module to be present.


zlib - http://php.net/manual/en/book.zlib.php


If you just need a generic wrapper to decode based on a given method name, use an array instead:

 $decode = array(
     "gzip" => "gzdecode",
     "deflate" => "gzinflate",
     "compress" => "gzuncompress",
     "x-gzip" => "gzdecode",
     "x-deflate" => "gzinflate",
     "x-compress" => "gzuncompress",
 );

Then instead of decode($bin, "x-gzip") you just use:

 $uncompressed = $decode["x-gzip"]($bin_data);

Though I wonder about the use case. And maybe you'll better wrap it in a function.. :}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜