Recently, I was developing my Wordpress plug-in ShareLink. During this process, I found the PHP class of the zip file operated by PclZip, which I have to recommend. Another reason for the recommendation is that the source code of the PHP function allows me to find the loose usage of a PHP function parameter. The following is an example.
Generate a zip file
Usage 1:
| The Code is as follows: |
Copy code |
<? Php Include_once ('pclzip. lib. php '); $ Archive = new PclZip('archive.zip '); $ V_list = $ archive-> create('file.txt, data/text.txt, folder '); If ($ v_list = 0 ){ Die ("Error:". $ archive-> errorInfo (true )); } ?> |
Usage 2:
| The Code is as follows: |
Copy code |
<? Php Include_once ('pclzip. lib. php '); $ Archive = new PclZip('archive.zip '); $ V_list = $ archive-> create ('data/file.txt, data/text.txt ', PCLZIP_OPT_REMOVE_PATH, 'data ', PCLZIP_OPT_ADD_PATH, 'install '); If ($ v_list = 0 ){ Die ("Error:". $ archive-> errorInfo (true )); } ?> |
If you see no parameters for the create method, you can see the method prototype. At least I have never used it.