Home > Backend Development > PHP Tutorial > How to compress and decompress strings in php, decompress strings in php_PHP tutorial

How to compress and decompress strings in php, decompress strings in php_PHP tutorial

WBOY
Release: 2016-07-13 10:03:42
Original
804 people have browsed it

How to compress and decompress strings in php, how to decompress strings in php

The example in this article describes how to compress and decompress strings in php. Share it with everyone for your reference. The details are as follows:

The following php code compresses and decompresses strings through gzcompress and gzuncompress, and you can set the compression level

$str = 'Hello I am a very very very very long string';
$compressed = gzcompress($str, 9);//压缩级别为9
$uncompressed = gzuncompress($compressed);
echo $str, "\n";
echo $uncompressed, "\n";
echo base64_encode($compressed), "\n";
echo bin2hex($compressed), "\n";
echo urlencode($compressed), "\n";
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/967742.htmlTechArticleHow to compress and decompress strings in php, decompress strings in php This article explains how to compress and decompress strings in php method. Share it with everyone for your reference. The details are as follows: Below...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template