本文整理汇总了PHP中ZipArchive::addPattern方法的典型用法代码示例。如果您正苦于以下问题:PHP ZipArchive::addPattern方法的具体用法?PHP ZipArchive::addPattern怎么用?PHP ZipArchive::addPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZipArchive
的用法示例。
在下文中一共展示了ZipArchive::addPattern方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ZipArchive
<?php
$zip = new ZipArchive();
$ret = $zip->open('./banners.zip', ZipArchive::OVERWRITE);
if ($ret !== TRUE) {
printf('Failed with code %d', $ret);
} else {
$directory = realpath('.');
$options = array('add_path' => ' ', 'remove_path' => $directory);
$zip->addPattern('/\\.html$/', $directory, $options);
$zip->close();
}
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=banners.zip');
header('Content-Length: ' . filesize('./banners.zip'));
readfile('./banners.zip');
示例2: dirname
<?php
$dirname = dirname(__FILE__) . '/';
include $dirname . 'utils.inc';
$file = $dirname . '__tmp_oo_addpattern.zip';
copy($dirname . 'test.zip', $file);
touch($dirname . 'foo.txt');
touch($dirname . 'bar.txt');
$zip = new ZipArchive();
if (!$zip->open($file)) {
exit('failed');
}
$dir = realpath($dirname);
$options = array('add_path' => 'baz/', 'remove_path' => $dir);
if (!$zip->addPattern('/\\.txt$/', $dir, $options)) {
echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
dump_entries_name($zip);
$zip->close();
} else {
echo "failed\n";
}
示例3: ZipArchive
<?php
$z = new ZipArchive();
$z->open('a.zip', ZIPARCHIVE::CREATE);
/* or 'remove_all_path' => 0*/
$options = array('remove_path' => '/home/pierre/cvs/gd/libgd/tests', 'add_path' => 'images/');
$found = $z->addPattern("/(\\.png)\$/i", "/home/pierre/cvs/gd/libgd/tests", $options);
var_dump($found);
$z->close();