You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
648 B

  1. <?php
  2. error_reporting(E_ALL);
  3. $thisdir = dirname(__FILE__);
  4. unlink("./test112.zip");
  5. $zip = new ZipArchive();
  6. $filename = "./test112.zip";
  7. if (!$zip->open($filename, ZIPARCHIVE::CREATE)) {
  8. exit("cannot open <$filename>\n");
  9. } else {
  10. echo "file <$filename> OK\n";
  11. }
  12. $zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");
  13. $zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n");
  14. $zip->addFile($thisdir . "/too.php","/testfromfile.php");
  15. echo "numfiles: " . $zip->numFiles . "\n";
  16. echo "status:" . $zip->status . "\n";
  17. $zip->close();
  18. unset($zip);