3v4l.org

run code in 300+ PHP versions simultaneously
<?phprequire_once dirname(__FILE__) . '/pclzip/pclzip.lib.php';/** * This is an enhanced version of PclZip class with the following * functionalities added: * - support for adding empty folders * - support for adding files with completely changed local name, not only path * - compression algorithm info added to file info */class ziparchive_PclZip extends PclZip{ /** * @param string $name * @return array|int */ public function addEmptyFolder($name) { return $this->privAdd(array( array( 'filename' => (string) $name, 'type' => 'virtual_folder', ), ), $p_result_list, $p_options); } /** * @param string $p_filename * @param array &$p_header * @return int */ protected function privAddVirtualFolder($p_filename, &$p_header = null) { $p_filename = trim($p_filename, '/\\') . '/'; $p_header['version'] = 20; $p_header['version_extracted'] = 10; $p_header['flag'] = 0; $p_header['compression'] = 0; $p_header['crc'] = 0; $p_header['size'] = 0; $p_header['compressed_size'] = 0; $p_header['disk'] = 0; $p_header['offset'] = 0; $p_header['internal'] = 0; $p_header['external'] = 0x00000010; $p_header['status'] = 'ok'; $p_header['index'] = -1; $p_header['mtime'] = time(); $p_header['filename'] = $p_filename; $p_header['filename_len'] = strlen($p_filename); $p_header['stored_filename'] = $p_filename; $p_header['comment'] = ''; $p_header['comment_len'] = 0; $p_header['extra'] = ''; $p_header['extra_len'] = 0; return $this->privWriteFileHeader($p_header); } /** * @param array $p_filedescr_list * @param array $p_result_list * @param array $p_options * @return array */ function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) { // add virtual folders first, as they are not supported by the // parent implementation $v_result = 1; $v_nb = count($p_result_list); for ($i = 0; ($i < count($p_filedescr_list)) && ($v_result == 1); ++$i) { $p_filedescr = &$p_filedescr_list[$i]; // ensure file names have no trailing slashes - as might be the // case when the original file name is completely removed by // PCLZIP_OPT_ADD_PATH and PCLZIP_OPT_REMOVE_PATH options in add() if (strpos($p_filedescr['type'], 'file') !== false && substr($p_filedescr['stored_filename'], -1) === '/' ) { $p_filedescr['stored_filename'] = substr($p_filedescr['stored_filename'], 0, -1); } if ($p_filedescr['type'] === 'virtual_folder') { $v_result = $this->privAddVirtualFolder($p_filedescr['filename'], $v_header); if ($v_result != 1) { return $v_result; } $p_result_list[$v_nb++] = $v_header; unset($p_filedescr_list[$i]); } } $p_filedescr_list = array_values($p_filedescr_list); $v_result = parent::privAddFileList($p_filedescr_list, $p_result_list, $p_options); return $v_result; } /** * @param array $p_header * @param array &$p_info * @return int */ function privConvertHeader2FileInfo($p_header, &$p_info) { $v_result = PclZip::privConvertHeader2FileInfo($p_header, $p_info); if ($v_result === 1) { $p_info['compression'] = $p_header['compression']; } return $v_result; }}<?phprequire_once dirname(__FILE__) . '/pclzip/pclzip.lib.php';/** * This is an enhanced version of PclZip class with the following * functionalities added: * - support for adding empty folders * - support for adding files with completely changed local name, not only path * - compression algorithm info added to file info */class ziparchive_PclZip extends PclZip{ /** * @param string $name * @return array|int */ public function addEmptyFolder($name) { return $this->privAdd(array( array( 'filename' => (string) $name, 'type' => 'virtual_folder', ), ), $p_result_list, $p_options); } /** * @param string $p_filename * @param array &$p_header * @return int */ protected function privAddVirtualFolder($p_filename, &$p_header = null) { $p_filename = trim($p_filename, '/\\') . '/'; $p_header['version'] = 20; $p_header['version_extracted'] = 10; $p_header['flag'] = 0; $p_header['compression'] = 0; $p_header['crc'] = 0; $p_header['size'] = 0; $p_header['compressed_size'] = 0; $p_header['disk'] = 0; $p_header['offset'] = 0; $p_header['internal'] = 0; $p_header['external'] = 0x00000010; $p_header['status'] = 'ok'; $p_header['index'] = -1; $p_header['mtime'] = time(); $p_header['filename'] = $p_filename; $p_header['filename_len'] = strlen($p_filename); $p_header['stored_filename'] = $p_filename; $p_header['comment'] = ''; $p_header['comment_len'] = 0; $p_header['extra'] = ''; $p_header['extra_len'] = 0; return $this->privWriteFileHeader($p_header); } /** * @param array $p_filedescr_list * @param array $p_result_list * @param array $p_options * @return array */ function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) { // add virtual folders first, as they are not supported by the // parent implementation $v_result = 1; $v_nb = count($p_result_list); for ($i = 0; ($i < count($p_filedescr_list)) && ($v_result == 1); ++$i) { $p_filedescr = &$p_filedescr_list[$i]; // ensure file names have no trailing slashes - as might be the // case when the original file name is completely removed by // PCLZIP_OPT_ADD_PATH and PCLZIP_OPT_REMOVE_PATH options in add() if (strpos($p_filedescr['type'], 'file') !== false && substr($p_filedescr['stored_filename'], -1) === '/' ) { $p_filedescr['stored_filename'] = substr($p_filedescr['stored_filename'], 0, -1); } if ($p_filedescr['type'] === 'virtual_folder') { $v_result = $this->privAddVirtualFolder($p_filedescr['filename'], $v_header); if ($v_result != 1) { return $v_result; } $p_result_list[$v_nb++] = $v_header; unset($p_filedescr_list[$i]); } } $p_filedescr_list = array_values($p_filedescr_list); $v_result = parent::privAddFileList($p_filedescr_list, $p_result_list, $p_options); return $v_result; } /** * @param array $p_header * @param array &$p_info * @return int */ function privConvertHeader2FileInfo($p_header, &$p_info) { $v_result = PclZip::privConvertHeader2FileInfo($p_header, $p_info); if ($v_result === 1) { $p_info['compression'] = $p_header['compression']; } return $v_result; }}

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0030.01418.25
8.3.50.0140.00422.91
8.3.40.0140.00018.70
8.3.30.0140.00019.09
8.3.20.0070.00020.16
8.3.10.0000.00821.89
8.3.00.0060.00317.50
8.2.180.0140.00716.35
8.2.170.0140.00322.96
8.2.160.0130.00020.39
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0030.01026.16
8.2.120.0040.00420.89
8.2.110.0060.00322.29
8.2.100.0030.00817.78
8.2.90.0070.00019.23
8.2.80.0050.00317.97
8.2.70.0000.01017.50
8.2.60.0050.00317.80
8.2.50.0030.00518.07
8.2.40.0000.00818.14
8.2.30.0000.00817.96
8.2.20.0000.00717.48
8.2.10.0040.00417.86
8.2.00.0040.00417.44
8.1.280.0120.00325.92
8.1.270.0050.00323.84
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00322.42
8.1.230.0090.00320.89
8.1.220.0030.00518.77
8.1.210.0030.00518.87
8.1.200.0040.00417.23
8.1.190.0040.00417.10
8.1.180.0040.00418.10
8.1.170.0030.00618.45
8.1.160.0000.00821.99
8.1.150.0040.00418.63
8.1.140.0050.00317.28
8.1.130.0070.00017.81
8.1.120.0050.00217.42
8.1.110.0030.00717.32
8.1.100.0000.00717.24
8.1.90.0030.00317.24
8.1.80.0000.00717.37
8.1.70.0000.00717.31
8.1.60.0000.00917.43
8.1.50.0050.00317.39
8.1.40.0000.00817.27
8.1.30.0030.00617.40
8.1.20.0000.00717.37
8.1.10.0000.00817.39
8.1.00.0040.00417.38
8.0.300.0000.00819.83
8.0.290.0070.00016.58
8.0.280.0030.00318.29
8.0.270.0040.00417.11
8.0.260.0070.00017.16
8.0.250.0070.00016.80
8.0.240.0070.00016.80
8.0.230.0030.00316.74
8.0.220.0070.00016.66
8.0.210.0040.00416.64
8.0.200.0000.00716.86
8.0.190.0040.00416.83
8.0.180.0040.00416.71
8.0.170.0080.00016.85
8.0.160.0030.00516.87
8.0.150.0000.00716.68
8.0.140.0040.00416.57
8.0.130.0050.00013.35
8.0.120.0000.00816.63
8.0.110.0040.00416.63
8.0.100.0070.00016.61
8.0.90.0030.00316.64
8.0.80.0030.01216.81
8.0.70.0030.00516.76
8.0.60.0000.00716.61
8.0.50.0040.00416.55
8.0.30.0160.00517.04
8.0.20.0120.00817.40
8.0.10.0000.00716.91
8.0.00.0140.00316.59
7.4.330.0050.00015.00
7.4.320.0030.00316.48
7.4.300.0060.00016.49
7.4.290.0070.00016.41
7.4.280.0000.00716.41
7.4.270.0040.00416.41
7.4.260.0040.00416.39
7.4.250.0000.00816.32
7.4.240.0060.00216.41
7.4.230.0000.00716.24
7.4.220.0100.01016.49
7.4.210.0090.00616.51
7.4.200.0000.00716.30
7.4.160.0170.00316.21
7.4.150.0100.00717.40
7.4.140.0070.01017.86
7.4.130.0100.01016.25
7.4.120.0080.00916.45
7.4.110.0050.01416.43
7.4.100.0060.01016.48
7.4.90.0150.00316.39
7.4.80.0100.00719.39
7.4.70.0170.00016.23
7.4.60.0190.00316.31
7.4.50.0030.00616.14
7.4.40.0060.01316.41
7.4.30.0130.00716.18
7.3.330.0030.00313.01
7.3.320.0000.00513.08
7.3.310.0040.00416.08
7.3.300.0030.00316.08
7.3.290.0050.00816.07
7.3.280.0120.00516.10
7.3.270.0130.01017.40
7.3.260.0100.00716.27
7.3.240.0130.00316.22
7.3.230.0050.01616.39
7.3.210.0100.00616.26
7.3.200.0000.01919.39
7.3.190.0030.01316.43
7.3.180.0090.00616.08
7.3.170.0240.03916.27
7.3.160.0120.00816.38
7.2.330.0150.00316.43
7.2.320.0080.00816.47
7.2.310.0100.01016.34
7.2.300.0060.01316.48
7.2.290.0130.00316.51
5.4.320.0060.03912.46
5.4.310.0080.05012.46
5.4.300.0090.05312.46
5.4.290.0100.05212.46
5.4.280.0070.05412.36
5.4.270.0160.04412.35
5.4.260.0080.05512.36
5.4.250.0130.04912.35
5.4.240.0100.05212.35
5.4.230.0070.05512.34
5.4.220.0060.04812.35
5.4.210.0080.03812.35
5.4.200.0120.03912.35
5.4.190.0080.04412.34
5.4.180.0100.04112.34
5.4.170.0040.05512.36
5.4.160.0050.03912.35
5.4.150.0070.03912.34
5.4.140.0130.03812.03
5.4.130.0100.03912.02
5.4.120.0050.04511.98
5.4.110.0060.04011.97
5.4.100.0030.05211.97
5.4.90.0100.04811.97
5.4.80.0080.04811.97
5.4.70.0070.04911.96
5.4.60.0060.05011.96
5.4.50.0090.04811.97
5.4.40.0080.04911.96
5.4.30.0040.05111.96
5.4.20.0080.04911.95
5.4.10.0070.04911.96
5.4.00.0080.04811.44
5.3.290.0140.04812.80
5.3.280.0150.04712.71
5.3.270.0050.04412.72
5.3.260.0060.03912.72
5.3.250.0080.03712.72
5.3.240.0100.04012.72
5.3.230.0050.04812.71
5.3.220.0070.03912.68
5.3.210.0090.03712.68
5.3.200.0100.04112.68
5.3.190.0060.04212.68
5.3.180.0050.04212.67
5.3.170.0090.05212.67
5.3.160.0100.03412.68
5.3.150.0070.03712.68
5.3.140.0060.04712.66
5.3.130.0090.04512.66
5.3.120.0060.04512.65
5.3.110.0090.04112.66
5.3.100.0040.04412.12
5.3.90.0100.04512.09
5.3.80.0140.04712.08
5.3.70.0060.05912.08
5.3.60.0090.05412.07
5.3.50.0110.03912.00
5.3.40.0050.04812.00
5.3.30.0040.04511.95
5.3.20.0040.04711.72
5.3.10.0040.03911.69
5.3.00.0060.04011.68
5.2.170.0090.0369.19
5.2.160.0080.0349.20
5.2.150.0050.0399.19
5.2.140.0030.0439.19
5.2.130.0070.0309.15
5.2.120.0070.0359.15
5.2.110.0050.0349.16
5.2.100.0050.0419.16
5.2.90.0090.0329.16
5.2.80.0020.0349.15
5.2.70.0040.0349.15
5.2.60.0050.0369.10
5.2.50.0070.0369.07
5.2.40.0070.0379.04
5.2.30.0060.0409.03
5.2.20.0050.0399.01
5.2.10.0070.0368.93
5.2.00.0050.0418.79
5.1.60.0050.0358.07
5.1.50.0050.0348.07
5.1.40.0050.0348.05
5.1.30.0050.0368.40
5.1.20.0070.0358.43
5.1.10.0050.0358.14
5.1.00.0040.0378.15
5.0.50.0030.0306.63
5.0.40.0040.0296.48
5.0.30.0040.0436.30
5.0.20.0050.0266.27
5.0.10.0050.0266.25
5.0.00.0040.0406.24
4.4.90.0010.0244.78
4.4.80.0030.0224.75
4.4.70.0040.0214.75
4.4.60.0020.0214.76
4.4.50.0030.0224.77
4.4.40.0040.0324.70
4.4.30.0020.0234.76
4.4.20.0030.0234.84
4.4.10.0050.0204.85
4.4.00.0040.0314.76
4.3.110.0050.0204.67
4.3.100.0050.0204.66
4.3.90.0030.0224.64
4.3.80.0040.0344.59
4.3.70.0030.0224.63
4.3.60.0030.0224.63
4.3.50.0040.0224.63
4.3.40.0060.0304.54
4.3.30.0040.0203.30
4.3.20.0040.0143.27
4.3.10.0000.0183.23
4.3.00.0030.01715.91

preferences:
32.64 ms | 401 KiB | 5 Q