3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); $fh = fopen(__FILE__, 'r'); fseek($fh, __COMPILER_HALT_OFFSET__, SEEK_SET); $mh = new MimeHalt($fh); var_dump($mh); eval('?>' . $mh->getFile('/test.php')); exit; class MimeHalt { public $config; protected $fh; protected $offset_diff = 0; protected $offset_after_main_header = 0; protected $offset_after_first_file_header = 0; protected $mime_boundary; public function __construct($fh) { $this->fh = $fh; $this->offset_diff = ftell($this->fh); $this->init(); } public function init() { $this->offset_after_first_file_header = 0; $this->resetOffset(); $first_line = stream_get_line($this->fh, PHP_INT_MAX, "\n"); $matches = array(); if(!preg_match('/^content\-type: multipart\/related; boundary=(.+)(?:;\s+.+)?$/i', $first_line, $matches)) { throw new RuntimeException('Invalid or corrupt file'); } $this->mime_boundary = '--' . $matches[1]; $this->resetOffset(); $header = static::readNextHeaderChunk($this->fh); #var_dump(static::processHeader($header)); fseek($this->fh, strlen($this->mime_boundary) + 1, SEEK_CUR); $this->offset_after_main_header = ftell($this->fh) - $this->offset_diff; $json_header = static::readNextHeaderChunk($this->fh); $json_body = static::readNextBodyChunk($this->fh, $this->mime_boundary); #var_dump($json_body); $this->config = json_decode($json_body, true); $this->offset_after_first_file_header = ftell($this->fh) - $this->offset_diff; $this->resetOffset(); if(!is_array($this->config['offset_map']) || !count($this->config['offset_map'])) $this->buildOffsetMap(); } public function resetOffset() { fseek($this->fh, $this->offset_diff + $this->offset_after_first_file_header, SEEK_SET); } public function buildOffsetMap() { #echo "Starting to rebuild offset map starting at position ", ftell($this->fh), "\n"; fseek($this->fh, $this->offset_diff + $this->offset_after_main_header, SEEK_SET); $header_text = ''; while($header_text = static::readNextHeaderChunk($this->fh)) { $headers = static::processHeader($header_text); #var_dump([$headers, $header_text]); $this->config['offset_map'][$headers['Content-ID']] = ftell($this->fh); static::readNextBodyChunk($this->fh, $this->mime_boundary); } #var_dump($this->config['offset_map']); } public function getFile($filename) { $content_id = $this->config['files'][$filename]; $offset = $this->config['offset_map'][$content_id]; fseek($this->fh, $offset, SEEK_SET); return static::readNextBodyChunk($this->fh, $this->mime_boundary); } protected static function readNextHeaderChunk($fh) { $line = stream_get_line($fh, PHP_INT_MAX, "\n\n"); if($line === false) return false; return $line . "\n"; } protected static function readNextBodyChunk($fh, $boundary) { $line = stream_get_line($fh, PHP_INT_MAX, "\n" . $boundary . "\n"); $end_of_body_string = "\n" . $boundary . "--\n"; $eobs_length = strlen($end_of_body_string); if(substr($line, $eobs_length * -1) == $end_of_body_string) $line = substr($line, 0, $eobs_length * -1); return $line; } protected static function processHeader($header_text) { $headers = array(); $matches = array(); $found = preg_match_all('/^(.+): ((.|\r\n\s)+)\r?\n/m', $header_text, $matches, PREG_SET_ORDER); if($found) { foreach($matches as $set) $headers[ $set[1] ] = $set[2]; } return $headers; } } __halt_compiler();Content-type: multipart/related; boundary=mimehalt_outer X-MimeHalt-Version: 1.0.0 --mimehalt_outer Content-Type: application/json Content-ID: 100000001 { "files": { "/mimehalt.json": "100000001", "/test.php": "100000002" }, "dirs": [ "/" ], "offset_map": null } --mimehalt_outer Content-Type: application/x-php Content-ID: 100000002 <?php echo "Hello, world!"; ?> --mimehalt_outer--

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.0120.00918.68
8.3.50.0080.01321.27
8.3.40.0090.00619.32
8.3.30.0110.00420.29
8.3.20.0040.00420.34
8.3.10.0000.00822.09
8.3.00.0040.00420.89
8.2.180.0070.01116.63
8.2.170.0040.01122.96
8.2.160.0070.00720.52
8.2.150.0040.00424.18
8.2.140.0160.00324.66
8.2.130.0070.00726.16
8.2.120.0040.00419.67
8.2.110.0060.00322.26
8.2.100.0060.00618.09
8.2.90.0040.00419.42
8.2.80.0040.00419.28
8.2.70.0100.00018.00
8.2.60.0050.00518.05
8.2.50.0040.00418.13
8.2.40.0050.00318.16
8.2.30.0040.00418.13
8.2.20.0030.00518.01
8.2.10.0040.00418.12
8.2.00.0030.00918.06
8.1.280.0120.00625.92
8.1.270.0080.00024.66
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00623.98
8.1.230.0090.00319.34
8.1.220.0000.00917.74
8.1.210.0060.00318.77
8.1.200.0040.00417.60
8.1.190.0030.00517.68
8.1.180.0040.00419.07
8.1.170.0030.00618.78
8.1.160.0050.00222.25
8.1.150.0040.00418.88
8.1.140.0000.00817.70
8.1.130.0030.00317.95
8.1.120.0050.00217.71
8.1.110.0040.00417.64
8.1.100.0040.00417.73
8.1.90.0040.00417.71
8.1.80.0040.00417.66
8.1.70.0000.00717.66
8.1.60.0040.00417.85
8.1.50.0000.00817.79
8.1.40.0000.00817.63
8.1.30.0060.00317.95
8.1.20.0030.00617.89
8.1.10.0000.00817.71
8.1.00.0090.00317.80
8.0.300.0040.00418.77
8.0.290.0000.00917.18
8.0.280.0070.00018.64
8.0.270.0000.00717.43
8.0.260.0070.00017.18
8.0.250.0000.00717.36
8.0.240.0040.00417.37
8.0.230.0040.00417.20
8.0.220.0000.00717.22
8.0.210.0040.00417.30
8.0.200.0040.00417.32
8.0.190.0030.00717.32
8.0.180.0060.00617.32
8.0.170.0000.00917.30
8.0.160.0040.00417.22
8.0.150.0000.00717.24
8.0.140.0040.00417.29
8.0.130.0000.00613.70
8.0.120.0060.00317.11
8.0.110.0000.00817.16
8.0.100.0040.00417.28
8.0.90.0000.00717.16
8.0.80.0110.00617.24
8.0.70.0000.00817.39
8.0.60.0080.00017.33
8.0.50.0000.00817.29
8.0.30.0080.01217.20
8.0.20.0100.01317.56
8.0.10.0050.00317.19
8.0.00.0080.01316.87
7.4.330.0040.00215.00
7.4.320.0030.00316.91
7.4.300.0000.00616.88
7.4.290.0000.00716.89
7.4.280.0030.00316.89
7.4.270.0030.00316.93
7.4.260.0040.00416.79
7.4.250.0000.00716.83
7.4.240.0010.00716.84
7.4.230.0040.00416.85
7.4.220.0100.01716.96
7.4.210.0070.00916.91
7.4.200.0040.00416.76
7.4.190.0070.00016.78
7.4.160.0090.00916.79
7.4.150.0080.00817.40
7.4.140.0100.01117.86
7.4.130.0120.00916.94
7.4.120.0110.00716.88
7.4.110.0060.01316.76
7.4.100.0080.01216.84
7.4.90.0070.01316.73
7.4.80.0140.00319.39
7.4.70.0030.01516.88
7.4.60.0070.01116.88
7.4.50.0060.00316.80
7.4.40.0000.01722.77
7.4.30.0060.01316.79
7.4.10.0030.00915.20
7.4.00.0070.01015.15
7.3.330.0030.00313.48
7.3.320.0000.00613.64
7.3.310.0000.00716.68
7.3.300.0080.00016.70
7.3.290.0000.01416.75
7.3.280.0100.00716.76
7.3.270.0180.00317.40
7.3.260.0120.00616.73
7.3.250.0050.01316.71
7.3.240.0030.01316.63
7.3.230.0100.01016.89
7.3.210.0060.01316.71
7.3.200.0000.01819.39
7.3.190.0140.00516.82
7.3.180.0130.00516.75
7.3.170.0080.00816.76
7.3.160.0060.01116.79
7.3.130.0060.01215.05
7.3.120.0100.00914.99
7.3.110.0060.01315.16
7.3.100.0060.01015.30
7.3.90.0060.00915.11
7.3.80.0060.00715.11
7.3.70.0040.00815.14
7.3.60.0110.00815.10
7.3.50.0090.00614.91
7.3.40.0090.00415.11
7.3.30.0050.00715.04
7.3.20.0050.00816.79
7.3.10.0060.00916.78
7.3.00.0040.01016.93
7.2.330.0130.00717.01
7.2.320.0120.00916.98
7.2.310.0040.02217.02
7.2.300.0140.00416.95
7.2.290.0080.01017.07
7.2.260.0070.01315.26
7.2.250.0090.00915.30
7.2.240.0070.01115.23
7.2.230.0080.00715.29
7.2.220.0070.00715.29
7.2.210.0120.00515.14
7.2.200.0050.00915.19
7.2.190.0050.00815.22
7.2.180.0030.01315.29
7.2.170.0050.00715.02
7.2.160.0090.00315.08
7.2.150.0060.01317.00
7.2.140.0120.00617.17
7.2.130.0090.00917.19
7.2.120.0030.01017.17
7.2.110.0070.01317.23
7.2.100.0120.00817.31
7.2.90.0000.01517.08
7.2.80.0060.00917.08
7.2.70.0100.00717.33
7.2.60.0060.00616.95
7.2.50.0070.01117.24
7.2.40.0090.00917.10
7.2.30.0030.01416.98
7.2.20.0030.00617.07
7.2.10.0040.00816.99
7.2.00.0110.00716.92
7.1.330.0060.01015.93
7.1.320.0050.00815.92
7.1.310.0030.01216.08
7.1.300.0090.00515.95
7.1.290.0100.00616.02
7.1.280.0080.00615.87
7.1.270.0030.01115.86
7.1.260.0060.00815.92
7.1.250.0030.01016.03
7.1.240.0090.00616.15
7.1.230.0040.01415.77
7.1.220.0110.00616.05
7.1.210.0000.01016.17
7.1.200.0030.01415.96
7.1.190.0030.00915.79
7.1.180.0030.01116.05
7.1.170.0030.01416.11
7.1.160.0090.00915.78
7.1.150.0000.01715.83
7.1.140.0100.00616.20
7.1.130.0090.00616.08
7.1.120.0060.01015.99
7.1.110.0090.00616.22
7.1.100.0070.00716.22
7.1.90.0000.01216.00
7.1.80.0060.00615.91
7.1.70.0070.00516.80
7.1.60.0050.00616.71
7.1.50.0020.01616.47
7.1.40.0070.01016.09
7.1.30.0000.00915.68
7.1.20.0060.00315.71
7.1.10.0150.00015.78
7.1.00.0040.02219.29
7.0.330.0000.01515.69
7.0.320.0040.00815.71
7.0.310.0070.00715.66
7.0.300.0000.01015.68
7.0.290.0090.00915.42
7.0.280.0100.00715.58
7.0.270.0070.00715.59
7.0.260.0060.00915.75
7.0.250.0030.00715.86
7.0.240.0060.00915.69
7.0.230.0030.00815.80
7.0.220.0030.01015.86
7.0.210.0080.00815.37
7.0.200.0070.00416.29
7.0.190.0060.00615.54
7.0.180.0070.01015.46
7.0.170.0040.00415.80
7.0.160.0070.00715.75
7.0.150.0030.00615.61
7.0.140.0030.04018.76
7.0.130.0110.00015.76
7.0.120.0100.00715.73
7.0.110.0040.01215.66
7.0.100.0070.00715.63
7.0.90.0030.00615.59
7.0.80.0070.00715.48
7.0.70.1920.01617.88
7.0.60.0070.04017.90
7.0.50.0050.03516.95
7.0.40.0050.02917.05
7.0.30.0080.03016.92
7.0.20.0130.02516.93
7.0.10.0190.04217.02
7.0.00.0120.03017.07
5.6.400.0040.01114.77
5.6.390.0070.00714.93
5.6.380.0030.01215.02
5.6.370.0000.01114.84
5.6.360.0090.00914.59
5.6.350.0030.01214.80
5.6.340.0030.00614.72
5.6.330.0140.00314.43
5.6.320.0130.00014.73
5.6.310.0000.01114.72
5.6.300.0030.01014.52
5.6.290.0080.00014.44
5.6.280.0080.03817.93
5.6.270.0040.00814.74
5.6.260.0060.00914.65
5.6.250.0070.00414.44
5.6.240.0090.00614.96
5.6.230.0130.00314.80
5.6.220.0040.00814.43
5.6.210.0140.01517.65
5.6.200.0090.04516.46
5.6.190.0100.02717.46
5.6.180.0070.02817.52
5.6.170.0250.04017.82
5.6.160.0060.04117.59
5.6.150.0060.02916.44
5.6.140.0050.04916.61
5.6.130.0120.04116.44
5.6.120.0050.03217.94
5.6.110.0070.02217.91
5.6.100.0020.05018.04
5.6.90.0120.04017.90
5.6.80.0110.04217.58
5.6.70.0150.04217.52
5.6.60.0070.00414.68
5.6.50.0030.00614.82
5.6.40.0030.00914.39
5.6.30.0030.00814.27
5.6.20.0080.00414.68
5.6.10.0040.00814.46
5.6.00.0030.00914.52
5.5.380.0000.01314.53
5.5.370.0030.00914.63
5.5.360.0000.01514.54
5.5.350.0050.04217.57
5.5.340.0030.04716.43
5.5.330.0100.04317.51
5.5.320.0060.04517.54
5.5.310.0080.03817.46
5.5.300.0080.04216.40
5.5.290.0030.04416.40
5.5.280.0050.03617.88
5.5.270.0070.02317.78
5.5.260.0080.03317.65
5.5.250.0110.04017.62
5.5.240.0060.04617.39
5.5.230.0030.01314.59
5.5.220.0060.00614.66
5.5.210.0000.01114.86
5.5.200.0000.00914.65
5.5.190.0000.01514.72
5.5.180.0140.00014.48
5.5.170.0030.00914.73
5.5.160.0090.00014.70
5.5.150.0060.00914.70
5.5.140.0040.01114.84
5.5.130.0110.00314.55
5.5.120.0050.00514.80
5.5.110.0090.00414.65
5.5.100.0100.00314.55
5.5.90.0040.01114.52
5.5.80.0030.01014.67
5.5.70.0030.00614.78
5.5.60.0080.00614.53
5.5.50.0030.00914.69
5.5.40.0080.00314.26
5.5.30.0100.00014.50
5.5.20.0000.00914.48
5.5.10.0030.00914.47
5.5.00.0030.01214.28
5.4.450.0280.03015.41
5.4.440.0500.02315.52
5.4.430.0410.02315.58
5.4.420.0330.03115.43
5.4.410.0370.03415.32
5.4.400.0230.02615.09
5.4.390.0080.03515.28
5.4.380.0070.03214.84
5.4.370.0130.02015.10
5.4.360.0190.02215.01
5.4.350.0040.02011.74
5.4.340.0050.03011.73
5.4.330.0000.01011.13
5.4.320.0060.02111.97
5.4.310.0050.02211.94
5.4.300.0070.02611.91
5.4.290.0040.02812.04
5.4.280.0050.02412.00
5.4.270.0060.02012.01
5.4.260.0020.03011.96
5.4.250.0040.03515.18
5.4.240.0100.03015.22
5.4.230.0070.02715.23
5.4.220.0100.03015.19
5.4.210.0050.03915.06
5.4.200.0130.02315.01
5.4.190.0100.03515.20
5.4.180.0060.02814.91
5.4.170.0080.03015.08
5.4.160.0100.02515.03
5.4.150.0040.03315.14
5.4.140.0030.03013.79
5.4.130.0060.02813.97
5.4.120.0030.02713.90
5.4.110.0060.04313.85
5.4.100.0100.02613.99
5.4.90.0050.03013.99
5.4.80.0060.02814.01
5.4.70.0050.04013.79
5.4.60.0080.02813.89
5.4.50.0050.03013.80
5.4.40.0050.02713.79
5.4.30.0100.03313.88
5.4.20.0080.03513.90
5.4.10.0030.03013.86
5.4.00.0140.03013.67
5.3.290.0030.02711.74
5.3.280.0080.02712.60
5.3.270.0090.03412.71
5.3.260.0070.03012.70
5.3.250.0100.02712.73
5.3.240.0050.03912.60
5.3.230.0080.02512.77
5.3.220.0100.02512.69
5.3.210.0080.03012.69
5.3.200.0070.03012.71
5.3.190.0060.03312.72
5.3.180.0060.02812.86
5.3.170.0050.04012.76
5.3.160.0070.02812.77
5.3.150.0070.04212.84
5.3.140.0080.02912.84
5.3.130.0110.02612.75
5.3.120.0100.03812.70
5.3.110.0080.02912.65
5.3.100.0070.03212.46
5.3.90.0070.03912.51
5.3.80.0030.03012.45
5.3.70.0050.02912.56
5.3.60.0030.02812.32
5.3.50.0030.03512.43
5.3.40.0080.03512.24
5.3.30.0050.02912.27
5.3.20.0080.02712.13
5.3.10.0050.02712.09
5.3.00.0030.02812.17
5.2.170.0070.04011.14
5.2.160.0030.04011.24
5.2.150.0070.04311.32
5.2.140.0030.05011.17
5.2.130.0100.04311.07
5.2.120.0030.06010.94
5.2.110.0030.05311.27
5.2.100.0070.04011.20
5.2.90.0100.03711.10
5.2.80.0070.04011.09
5.2.70.0100.03711.06
5.2.60.0100.04011.15
5.2.50.0070.03711.20
5.2.40.0070.03711.12
5.2.30.0000.04311.21
5.2.20.0100.04010.88
5.2.10.0170.03310.95
5.2.00.0200.04310.74
5.1.60.0130.02710.07
5.1.50.0030.03710.01
5.1.40.0100.02710.00
5.1.30.0070.03310.42
5.1.20.0200.03310.45
5.1.10.0070.04310.28
5.1.00.0000.04010.05
5.0.50.0000.0338.63
5.0.40.0000.0338.38
5.0.30.0100.0408.48
5.0.20.0100.0208.21
5.0.10.0070.0308.18
5.0.00.0030.0408.16
4.4.90.0030.0207.49
4.4.80.0000.0277.49
4.4.70.0100.0207.49
4.4.60.0070.0207.49
4.4.50.0070.0177.49
4.4.40.0070.0437.49
4.4.30.0100.0237.49
4.4.20.0070.0277.49
4.4.10.0000.0337.49
4.4.00.0000.0337.49
4.3.110.0030.0307.49
4.3.100.0030.0237.49
4.3.90.0000.0237.49
4.3.80.0100.0307.49
4.3.70.0100.0137.49
4.3.60.0100.0237.49
4.3.50.0030.0307.49
4.3.40.0000.0377.49
4.3.30.0030.0207.49
4.3.20.0030.0207.49
4.3.10.0000.0307.49
4.3.00.0100.0207.27

preferences:
55.69 ms | 400 KiB | 5 Q