3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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();
Output for 7.0.0 - 7.1.0
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 hhvm-3.12.0 - 3.13.2
Fatal error: Uncaught Error: Call to undefined method ZipArchive::setPassword() in /in/Hj0Ot:12 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.2.1 - 5.3.29, hhvm-3.10.0
Fatal error: Call to undefined method ZipArchive::setPassword() in /in/Hj0Ot on line 12
Process exited with code 255.
Output for 5.4.0 - 5.6.29
Fatal error: Class 'ZipArchive' not found in /in/Hj0Ot on line 9
Process exited with code 255.
Output for 5.0.0 - 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.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.