Compress gzip string

我是研究僧i 提交于 2019-12-11 07:49:18

问题


I want to compress a string in PHP and write it to a file without using the gzwrite function as I want to store the actual compressed string in a database first, but I am unsure as whether to use gzcompress, gzencode or gzdeflate as it's not very clear.

Any ideas?

  • Edit: the already compressed string will be written into a *.gz file from the database so it has to be compatible.

回答1:


Use gzcompress if you just want to compress the string. gzencode will also add gzip file headers so it can be uncompressed directly by gzip and similar tools.

gzdeflate uses the deflate algorithm which is very similar to the first one.

I think yo want to use gzencode in ths case since the data is going to be stored as a file.



来源:https://stackoverflow.com/questions/5882965/compress-gzip-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!