addFromString(...)" Can."/> addFromString(...)" Can.">
Home > Article > Backend Development > How to use php ziparchive
php ziparchive usage: first open the test.zip file; then add the image.txt file to test.zip; finally add the image.txt file to the zip file through "$zip->addFromString(...)" Just append content to the test.txt file.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
php experience using ZipArchive to compress files
$zip=new ZipArchive; if($zip->open('test.zip',ZipArchive::CREATE)===TRUE){ $zip->addFile('image.txt');//假设在当前路径下加入的文件名是image.txt $zip->close(); }
Function: Open the test.zip file by default, create a test.zip file if it does not exist, and then add the image.txt file to test.zip.
Note: If image.txt is not added to the created zip file, the created compressed package will not be visible.
$zip->addFromString('test.txt','file content goes here');
Function: Append content to the test.txt file in the zip file
[Recommended learning: "PHP Video Tutorial"]
The above is the detailed content of How to use php ziparchive. For more information, please follow other related articles on the PHP Chinese website!