There are many string compression methods provided by php. below we will compare the php string compression methods. if you are interested, refer to the following string compression methods provided by php:
1. gzcompress-Compress a string
This function compress the given string using the ZLIB data format.
2. gzencode-Create a gzip compressed string
This function returns a compressed version of the input data compatible with the output of the gzip program
3. gzdeflate-Deflate a string
This function compress the given string using the DEFLATE data format.
4. bzcompress-compress a string into bzip2 encoded data
Bzcompress () compresses the specified string and returns data in bzip2 encoding.
The following four methods are used for compression and comparison, and Chinese and English numbers are compressed respectively.
The code is as follows:
$ Str1 = 'layout 1 describes the layout, which is simply to set the size and position of the element. The layout system of Ext includes components, layout, containers, and containers. it is a special component that allows you to manage the size and position of components. The container recalculates the layout through doLayout and updates the DOM. 2 manual layout. The framework will automatically process the layout for you. ';
/* Get microtime */
Function get_microtime (){
List ($ usec, $ sec) = explode ('', microtime (true ));
Return $ usec + $ sec;
}
?>
Execution result:
The code is as follows:
Compressed Chinese comparison
Original article: Layout 1 describes the layout, which is simply to set the size and position of elements. The layout system of Ext includes components, layout, containers, and containers. it is a special component that allows you to manage the size and position of components. The container recalculates the layout through doLayout and updates the DOM. 2 manual layout. The framework will automatically process the layout for you.
Original article size: 328
Size after gzcompress compression: 251 elapsed time: 59.99994 ms
Size after gzencode compression: 263 elapsed time: 120.00012 ms
Size after gzdeflate compression: 245 elapsed time: 119.99989 ms
Size after bzcompress compression: 303 elapsed time: 259.99999 ms
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.