當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zip::addDirectoryContent方法代碼示例

本文整理匯總了PHP中Zip::addDirectoryContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zip::addDirectoryContent方法的具體用法?PHP Zip::addDirectoryContent怎麽用?PHP Zip::addDirectoryContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zip的用法示例。


在下文中一共展示了Zip::addDirectoryContent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: date

<?php

// Example. Zip all .html files in the current directory and send the file for Download.
// Also adds a static text "Hello World!" to the file Hello.txt
$fileDir = './';
ob_start();
// This is only to show that ob_start can be called, however the buffer must be empty when sending.
include_once "Zip.php";
$fileTime = date("D, d M Y H:i:s T");
$zip = new Zip();
$zip->setComment("Example Zip file.\nCreated on " . date('l jS \\of F Y h:i:s A'));
$zip->addFile("Hello World!", "hello.txt");
@($handle = opendir($fileDir));
if ($handle) {
    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) {
        if (strpos($file, ".html") !== false) {
            $pathData = pathinfo($fileDir . $file);
            $fileName = $pathData['filename'];
            $zip->addFile(file_get_contents($fileDir . $file), $file, filectime($fileDir . $file));
        }
    }
}
// Add a directory, first recursively, then the same directory, but without recursion.
// Naturally this requires you to change the path to ../test to point to a directory of your own.
$zip->addDirectoryContent("testData/test", "recursiveDir/test");
$zip->addDirectoryContent("testData/test", "recursiveDir/testFlat", FALSE);
$zip->sendZip("ZipExample1.zip");
開發者ID:vrtulka23,項目名稱:daiquiri,代碼行數:28,代碼來源:Zip.Example1.php


注:本文中的Zip::addDirectoryContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。