如何将PHP实现文件压缩的简单方法改写为长尾关键词?
- 内容介绍
- 文章标签
- 相关推荐
本文共计698个文字,预计阅读时间需要3分钟。
压缩一个文件,我们将一个文件生成一个压缩包。PHP代码如下:
php$zip=new ZipArchive();$zip->open(test.zip, ZipArchive::CREATE);$zip->addFile(c:/wamp/www/log.txt, basename(c:/wamp/www/log.txt));$zip->close();
压缩一个文件
我们将一个文件生成一个压缩包。
<?php $path = "c:/wamp/www/log.txt"; $filename = "test.zip"; $zip = new ZipArchive(); $zip->open($filename,ZipArchive::CREATE); //打开压缩包 $zip->addFile($path,basename($path)); //向压缩包中添加文件 $zip->close(); //关闭压缩包
上述代码将c:/wamp/www/log.txt文件压缩生成了test.zip,并保存在当前目录。
压缩多个文件
压缩多个文件,其实就是addFile执行多次,可以通过数组的遍历来实现。
本文共计698个文字,预计阅读时间需要3分钟。
压缩一个文件,我们将一个文件生成一个压缩包。PHP代码如下:
php$zip=new ZipArchive();$zip->open(test.zip, ZipArchive::CREATE);$zip->addFile(c:/wamp/www/log.txt, basename(c:/wamp/www/log.txt));$zip->close();
压缩一个文件
我们将一个文件生成一个压缩包。
<?php $path = "c:/wamp/www/log.txt"; $filename = "test.zip"; $zip = new ZipArchive(); $zip->open($filename,ZipArchive::CREATE); //打开压缩包 $zip->addFile($path,basename($path)); //向压缩包中添加文件 $zip->close(); //关闭压缩包
上述代码将c:/wamp/www/log.txt文件压缩生成了test.zip,并保存在当前目录。
压缩多个文件
压缩多个文件,其实就是addFile执行多次,可以通过数组的遍历来实现。

