HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //opt/remi/php83/root/usr/share/doc/pecl/zip/examples/set_compression.php
<?php
error_reporting(E_ALL);
if (!extension_loaded('zip')) {
    dl('zip.so');
}

$zip = new ZipArchive();
$filename = "a.zip";

if (!$zip->open($filename, ZIPARCHIVE::CREATE | ZipArchive::OVERWRITE)) {
	exit("cannot open <$filename>\n");
}

$zip->addFromString("testfilephp.txt", "#1 This is a test string added as testfilephp.txt.\n");
$zip->addFromString("testfilephp2.txt", "#2 This is a test string added as testfilephp2.txt.\n");
$zip->addFile("too.php", "testfromfile.php");

$zip->setCompressionName("testfilephp2.txt", ZipArchive::CM_STORE);
$zip->setCompressionIndex(2, ZipArchive::CM_STORE);

$zip->close();