dongtao5104 2017-03-30 08:16
浏览 89
已采纳

ZipArchive中的多行注释

I am trying to set a multi-line comment with ZipArchive.Below is a simplified demo.

<?php
$comment = "File \t Stats
";
$comment .= "Second line ...some another text 
";
$zip->setArchiveComment($comment);

I then open the zip file with Winrar on my windows machine and in the comment you can see , \t appearing as is ... indicating that either winrar don't allow this or i wrong set the zipArchive comment.

  • 写回答

1条回答 默认 最新

  • dongzha5934 2017-04-01 10:23
    关注

    I cannot reproduce your problem based on your simplified demo. WinRAR displays it as expected. But I can mimic the result you get by using single quotes for the comment string.

    <?php
    $zip = new ZipArchive;
    $res = $zip->open('test.zip', ZipArchive::CREATE);
    if ($res === TRUE) {
        $zip->addFromString('test.txt', 'file content goes here');
    
        $zip->setArchiveComment("File \t Stats
    Second line ... some other text 
    "); // OK
        $comment = "File \t Stats
    ";
        $comment .= 'Second line ... some other text 
    ';
        $zip->setArchiveComment($comment); // NOT OK for the second line
    
        $zip->close();
        echo 'ok';
    } else {
        echo 'failed';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!