I carefully studied the efficiency of the decompression program written in php, which is much higher than I thought. since it is so good, I just need to optimize it and use it in my background, although the control panel in most of the space currently has the compression and decompression function, it is sometimes troublesome. do this... I carefully studied the efficiency of the decompression program written in php, which is much higher than I thought. since it is so good, I just need to optimize it and use it in my background, although the control panel in most of the space currently has the compression and decompression function, it is sometimes troublesome.
Before doing this, I have never touched on php compression. I have searched some websites on the internet. most of them are php compression classes and compression functions. if there are few hundred lines, there will be thousands of lines of code, this is hard for a newbie like me to understand. besides, I don't need such complex functions. finally, after reading the function manual and figuring out a few related functions, you will understand how to complete it.
PHP Zip File function
Remember to enable zip and remove the semicolon before extension = php_zip.dll in php. ini.
Sample code:
". $ I ++." This file has been skipped. cause: the file is too large.-> ". iconv (" gb2312 "," UTF-8 ", $ file_name )."";}}// Close the current zip_entry_close ($ dir_resource) ;}// close the zip package zip_close ($ resource); $ endtime = explode ('', microtime ()); // Extract end time $ thistime = $ endtime [0] + $ endtime [1]-($ starttime [0] + $ starttime [1]); $ thistime = round ($ thistime, 3); // retain 3 as a decimal echo"Decompress the package !, This decompression takes $ thistime seconds.
";}$ Size = get_zip_originalsize('331101.zip ', '1 generation Kerui/');?>
It took 300 seconds to decompress a small file with a size of more than 0.115 KB. it took more than 20 seconds to decompress a web file with a size of more than 30 MB.
Php decompression program
Compared with the system, it is indeed a little slower, but it is also very good, just getting started, the code is not good, but the implementation of understanding pressure, and the code is also easier to understand than the introduction of the Internet, if you see this article, I believe it is helpful to you. The program uses the running time. for details, see the code below:
// Read a maximum of 6 MB. if the file is too large, skip decompression and continue to the next step.
This part is not doing well, so it is impossible to decompress the large file, and will be optimized later.
Article address:
Reprint at will ^ please include the address of this article!