3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Get folder name $folder = $params['folder']; $zipFolder = $folder . '.zip'; // Get instance of ZipArchive $zipArchive = new ZipArchive(); // Open zip archive $zipArchive->open($zipFolder, ZIPARCHIVE::CREATE); $zipArchive->addEmptyDir($folder); //zipFolderFiles($folder, $zipArchive); // Close zip archive $zipArchive->close(); // Download archive header('Content-Type: application/zip'); header('Content-disposition: attachment; filename=' . $zipFolder); header('Content-Length: ' . filesize($zipFolder)); readfile($zipFolder); // Recursive zip creation function function zipFolderFiles($dir, &$zipArchive) { //$base_path = './uploads/tenders/'; //$ffs = scandir($base_path . $dir); //if (!is_array($ffs) || empty($ffs)) return; //foreach ($ffs as $ff) { // if ($ff != '.' && $ff != '..') { // if (is_dir($base_path . $dir . '/' . $ff)) { // $zipArchive->addEmptyDir($ff); // zipFolderFiles($dir . '/' . $ff, $zipArchive); // } else { // $zipArchive->addFile($base_path . $dir . '/' . $ff, $ff); // } // } //} }
Output for 8.3.0 - 8.3.6
Warning: Undefined variable $params in /in/quReB on line 4 Warning: Trying to access array offset on null in /in/quReB on line 4 Fatal error: Uncaught Error: Class "ZipArchive" not found in /in/quReB:8 Stack trace: #0 {main} thrown in /in/quReB on line 8
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Warning: Undefined variable $params in /in/quReB on line 4 Warning: Trying to access array offset on value of type null in /in/quReB on line 4 Fatal error: Uncaught Error: Class "ZipArchive" not found in /in/quReB:8 Stack trace: #0 {main} thrown in /in/quReB on line 8
Process exited with code 255.
Output for 7.4.26 - 7.4.33
Notice: Undefined variable: params in /in/quReB on line 4 Notice: Trying to access array offset on value of type null in /in/quReB on line 4 Fatal error: Uncaught Error: Class 'ZipArchive' not found in /in/quReB:8 Stack trace: #0 {main} thrown in /in/quReB on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.25
Fatal error: Uncaught Error: Class 'ZipArchive' not found in /in/quReB:8 Stack trace: #0 {main} thrown in /in/quReB on line 8
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/quReB on line 8
Process exited with code 255.
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29
Warning: filesize(): stat failed for .zip in /in/quReB on line 21 Warning: Cannot modify header information - headers already sent by (output started at /in/quReB:21) in /in/quReB on line 21 Warning: readfile(.zip): failed to open stream: No such file or directory in /in/quReB on line 22
Output for 5.2.1 - 5.2.2
<br /> <b>Warning</b>: filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for .zip in <b>/in/quReB</b> on line <b>21</b><br /> <br /> <b>Warning</b>: readfile(.zip) [<a href='function.readfile'>function.readfile</a>]: failed to open stream: No such file or directory in <b>/in/quReB</b> on line <b>22</b><br />
Output for 5.2.0
<br /> <b>Fatal error</b>: Call to undefined method ZipArchive::addEmptyDir() in <b>/in/quReB</b> on line <b>12</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
<br /> <b>Fatal error</b>: Class 'ZipArchive' not found in <b>/in/quReB</b> on line <b>8</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected ')', expecting '(' in <b>/in/quReB</b> on line <b>11</b><br />
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
<br /> <b>Parse error</b>: parse error, unexpected ')', expecting '(' in <b>/in/quReB</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `'('' in <b>/in/quReB</b> on line <b>11</b><br />
Process exited with code 255.

preferences:
340.13 ms | 401 KiB | 468 Q