当前位置: 首页>>代码示例>>PHP>>正文


PHP Zip::temp方法代码示例

本文整理汇总了PHP中Zip::temp方法的典型用法代码示例。如果您正苦于以下问题:PHP Zip::temp方法的具体用法?PHP Zip::temp怎么用?PHP Zip::temp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zip的用法示例。


在下文中一共展示了Zip::temp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: date

// 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");

// Set a temp file to use, instead of the default system temp file directory. 
// The temp file is used if the generated Zip file is becoming too large to hold in memory.
//Zip::$temp = "./tempFile";

// Setting this to a function to create the temp files requires PHP 5.3 or newer:
//Zip::$temp = function() { return tempnam(sys_get_temp_dir(), 'Zip');};
Zip::$temp = function() { return "./tempFile_" . rand(100000, 999999);};

$zip = new Zip();
// Archive comments don't really support utf-8. Some tools detect and read it though.
$zip->setComment("Example Zip file.\nCreated on " . date('l jS \of F Y h:i:s A'));
// A bit of russian (I hope), to test UTF-8 file names.
$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, ".php") !== false) {
            $pathData = pathinfo($fileDir . $file);
            $fileName = $pathData['filename'];
开发者ID:sg4r3z,项目名称:umvc,代码行数:29,代码来源:Zip.Example3.php


注:本文中的Zip::temp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。