@ 2014-06-12T17:22:10Z <?php
$zipFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'filename.zip';
$password = 'P455W0RD';
if (file_exists($zipFilePath)) {
unlink($zipFilePath);
}
$zipArchive = new ZipArchive();
$zipArchive->open($zipFilePath, ZipArchive::CREATE);
if ($zipArchive->setPassword($password)) {
echo 'OK' . PHP_EOL;
}
foreach (range(1, 10) as $fileNumber) {
$zipArchive->addFromString('file' . $fileNumber . '.txt', rand());
}
$zipArchive->close();
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.26 , 7.3.0 - 7.3.13 , 7.4.0 - 7.4.1 Fatal error: Uncaught Error: Class 'ZipArchive' not found in /in/Hj0Ot:9
Stack trace:
#0 {main}
thrown in /in/Hj0Ot on line 9
Process exited with code 255 . Output for 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 Fatal error: Class 'ZipArchive' not found in /in/Hj0Ot on line 9
Process exited with code 255 . Output for 5.2.1 - 5.2.17 , 5.3.0 - 5.3.29 Fatal error: Call to undefined method ZipArchive::setPassword() in /in/Hj0Ot on line 12
Process exited with code 255 . Output for 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 Fatal error: Call to undefined function sys_get_temp_dir() in /in/Hj0Ot on line 2
Process exited with code 255 . Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected ')', expecting '(' in /in/Hj0Ot on line 10
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected ')', expecting '(' in /in/Hj0Ot on line 10
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error, expecting `'('' in /in/Hj0Ot on line 10
Process exited with code 255 . preferences:dark mode live preview
208.99 ms | 401 KiB | 323 Q