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, 1048576, "\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 = MimeHalt::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 = MimeHalt::readNextHeaderChunk($this->fh); $json_body = MimeHalt::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 = MimeHalt::readNextHeaderChunk($this->fh)) { $headers = MimeHalt::processHeader($header_text); #var_dump([$headers, $header_text]); $this->config['offset_map'][$headers['Content-ID']] = ftell($this->fh); MimeHalt::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 MimeHalt::readNextBodyChunk($this->fh, $this->mime_boundary); } protected static function readNextHeaderChunk($fh) { $line = stream_get_line($fh, 1048576, "\n\n"); if($line === false) return false; return $line . "\n"; } protected static function readNextBodyChunk($fh, $boundary) { $line = stream_get_line($fh, 1048576, "\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.40.0150.00619.27
8.3.30.0130.00320.47
8.3.20.0040.00420.34
8.3.10.0030.00622.14
8.3.00.0000.00822.45
8.2.170.0060.01022.96
8.2.160.0110.00420.47
8.2.150.0030.00624.18
8.2.140.0060.01324.66
8.2.130.0100.01026.16
8.2.120.0080.00019.65
8.2.110.0070.00320.44
8.2.100.0040.00818.16
8.2.90.0060.00319.34
8.2.80.0030.00519.59
8.2.70.0050.00318.00
8.2.60.0050.00318.29
8.2.50.0030.00618.07
8.2.40.0000.00818.28
8.2.30.0040.00418.18
8.2.20.0040.00417.99
8.2.10.0040.00417.99
8.2.00.0080.00518.00
8.1.270.0090.00024.66
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0070.00423.77
8.1.230.0060.00622.69
8.1.220.0060.00317.91
8.1.210.0040.00418.77
8.1.200.0040.00417.63
8.1.190.0030.00517.39
8.1.180.0050.00519.14
8.1.170.0040.00418.79
8.1.160.0050.00222.18
8.1.150.0050.00318.77
8.1.140.0040.00417.74
8.1.130.0000.00718.00
8.1.120.0040.00417.66
8.1.110.0000.00817.63
8.1.100.0000.00817.60
8.1.90.0000.00817.63
8.1.80.0040.00417.73
8.1.70.0000.00717.67
8.1.60.0000.00917.86
8.1.50.0030.00517.83
8.1.40.0040.00417.75
8.1.30.0040.00417.84
8.1.20.0000.00817.97
8.1.10.0000.00817.80
8.1.00.0060.00617.81
8.0.300.0040.00418.77
8.0.290.0070.00017.18
8.0.280.0040.00418.54
8.0.270.0040.00417.30
8.0.260.0000.00717.25
8.0.250.0030.00417.38
8.0.240.0040.00417.34
8.0.230.0040.00417.26
8.0.220.0020.00517.32
8.0.210.0000.00717.17
8.0.200.0070.00017.20
8.0.190.0040.00417.20
8.0.180.0050.00517.33
8.0.170.0040.00417.21
8.0.160.0040.00417.33
8.0.150.0020.00517.12
8.0.140.0000.00817.13
8.0.130.0000.00613.71
8.0.120.0000.00817.26
8.0.110.0030.00517.10
8.0.100.0040.00417.32
8.0.90.0040.00417.25
8.0.80.0080.00817.30
8.0.70.0050.00317.13
8.0.60.0040.00417.16
8.0.50.0040.00417.16
8.0.30.0070.01317.31
8.0.20.0040.01617.45
8.0.10.0050.00217.34
8.0.00.0120.00717.08
7.4.330.0050.00215.00
7.4.320.0030.00316.87
7.4.300.0000.00616.90
7.4.290.0040.00416.92
7.4.280.0070.00016.81
7.4.270.0000.00716.96
7.4.260.0030.00616.75
7.4.250.0040.00416.79
7.4.240.0040.00416.81
7.4.230.0070.00016.82
7.4.220.0030.01616.95
7.4.210.0070.00916.92
7.4.200.0000.00716.93
7.4.190.0000.00716.96
7.4.160.0090.00916.97
7.4.150.0030.01617.40
7.4.140.0130.00617.86
7.4.130.0180.00316.86
7.4.120.0080.01116.82
7.4.110.0120.00616.97
7.4.100.0110.01416.71
7.4.90.0120.01516.81
7.4.80.0000.02119.39
7.4.70.0110.00816.91
7.4.60.0080.01316.84
7.4.50.0000.00916.93
7.4.40.0030.01422.77
7.4.30.0190.00416.75
7.4.00.0130.00315.20
7.3.330.0030.00313.72
7.3.320.0050.00013.80
7.3.310.0070.00016.77
7.3.300.0050.00216.66
7.3.290.0080.00816.67
7.3.280.0090.00716.75
7.3.270.0090.00917.40
7.3.260.0090.00916.80
7.3.250.0140.00416.77
7.3.240.0090.00916.86
7.3.230.0030.01316.84
7.3.210.0090.00916.71
7.3.200.0150.00319.39
7.3.190.0090.01216.61
7.3.180.0060.01116.80
7.3.170.0160.00616.93
7.3.160.0060.01116.80
7.3.120.0060.00914.97
7.2.330.0130.00616.99
7.2.320.0130.00716.98
7.2.310.0080.01217.00
7.2.300.0070.01117.04
7.2.290.0090.01316.91
7.1.200.0090.00316.09
7.1.70.0040.00417.37
7.1.60.0130.01319.21
7.1.50.0130.01017.23
7.1.00.0030.03322.50
7.0.200.0060.00615.31
7.0.140.0070.07321.93
7.0.60.0100.08320.02
7.0.50.0130.07318.09
7.0.40.0230.06320.18
7.0.30.0370.07020.09
7.0.20.0270.04020.36
7.0.10.0200.06720.23
7.0.00.0100.07020.25
5.6.280.0000.08021.16
5.6.210.0130.07720.73
5.6.200.0000.07718.30
5.6.190.0070.04020.67
5.6.180.0270.04320.62
5.6.170.0270.07320.53
5.6.160.0130.08320.57
5.6.150.0030.05318.29
5.6.140.0070.07718.23
5.6.130.0100.03718.20
5.6.120.0200.04321.07
5.6.110.0100.03721.16
5.6.100.0000.04721.09
5.6.90.0100.05021.12
5.6.80.0130.06320.46
5.6.70.0400.05320.55
5.5.350.0030.06020.37
5.5.340.0000.04718.00
5.5.330.0130.04320.41
5.5.320.0270.07720.28
5.5.310.0400.07020.39
5.5.300.0130.07318.08
5.5.290.0070.08018.00
5.5.280.0000.04720.82
5.5.270.0100.08320.80
5.5.260.0070.04020.91
5.5.250.0000.04320.74
5.5.240.0130.07320.40
5.4.450.0100.04019.65
5.4.440.0130.07319.29
5.4.430.0670.05319.28
5.4.420.1600.03319.17
5.4.410.1700.05019.34
5.4.400.1400.04319.00
5.4.390.1400.04319.15
5.4.380.1730.04719.32
5.4.370.1730.04018.87
5.4.360.1700.04719.23
5.4.350.1730.04718.99
5.4.340.1730.04319.29
5.4.320.1770.05019.11
5.4.310.1870.04719.20
5.4.300.1900.04319.20
5.4.290.1700.03719.09
5.4.280.2000.04319.22
5.4.270.1730.04019.16
5.4.260.1930.05019.14
5.4.250.2000.04719.07
5.4.240.1600.04018.84
5.4.230.1900.04719.19
5.4.220.1630.04019.15
5.4.210.1630.03719.08
5.4.200.1600.03719.09
5.4.190.1630.02718.94
5.4.180.1500.04018.98
5.4.170.1570.03319.31
5.4.160.1630.03319.25
5.4.150.2070.04318.95
5.4.140.1730.03016.47
5.4.130.1800.03016.40
5.4.120.1770.03016.72
5.4.110.1630.03716.59
5.4.100.1600.04016.55
5.4.90.1830.03016.59
5.4.80.1830.03716.44
5.4.70.1530.04016.50
5.4.60.0000.04716.40
5.4.50.0030.05316.50
5.4.40.1270.04316.57
5.4.30.1700.04316.56
5.4.20.1700.04316.57
5.4.10.1970.04316.27
5.4.00.0130.07715.97
5.3.290.1930.04714.72
5.3.280.1900.03714.80
5.3.270.1630.03014.75
5.3.260.1800.05314.57
5.3.250.1800.05014.65
5.3.240.1600.03714.75
5.3.230.0370.06314.65
5.3.220.0030.07714.72
5.3.210.0170.06314.65
5.3.200.1870.04014.62
5.3.190.1830.04714.72
5.3.180.1730.04014.73
5.3.170.1870.04314.61
5.3.160.1870.04314.66
5.3.150.1570.04014.62
5.3.140.1830.05014.55
5.3.130.1870.04714.65
5.3.120.1730.04314.75
5.3.110.1670.04314.86
5.3.100.0200.05014.02
5.3.90.0200.05713.87
5.3.80.0030.07313.94
5.3.70.0100.08714.02
5.3.60.0100.06013.91
5.3.50.0170.05713.84
5.3.40.0130.07013.85
5.3.30.0130.05313.96
5.3.20.0270.06013.62
5.3.10.0100.06313.59
5.3.00.0100.05713.55
5.2.170.1200.02310.97
5.2.160.0970.03711.06
5.2.150.1270.03311.02
5.2.140.1170.03310.93
5.2.130.0970.03011.07
5.2.120.0030.03011.00
5.2.110.0130.03711.17
5.2.100.0000.04010.94
5.2.90.1070.03010.93
5.2.80.1370.03011.02
5.2.70.1330.04011.16
5.2.60.1300.03310.89
5.2.50.1500.03710.77
5.2.40.0930.03710.83
5.2.30.1200.03310.90
5.2.20.1230.02310.87
5.2.10.1300.04010.81
5.2.00.1100.03310.54
5.1.60.1030.02710.29
5.1.50.1030.02010.11
5.1.40.0600.02710.27
5.1.30.0070.02010.35
5.1.20.0030.02310.43
5.1.10.0030.02310.06
5.1.00.0070.02310.05
5.0.50.0000.0209.29
5.0.40.0370.0279.29
5.0.30.0570.0339.29
5.0.20.0570.0209.29
5.0.10.0570.0209.29
5.0.00.0570.0279.29
4.4.90.0470.0179.29
4.4.80.0570.0139.29
4.4.70.0530.0179.29
4.4.60.0670.0179.29
4.4.50.0570.0139.29
4.4.40.0570.0239.29
4.4.30.0570.0139.29
4.4.20.0330.0179.29
4.4.10.0130.0179.29
4.4.00.0430.0279.29
4.3.110.0530.0139.29
4.3.100.0600.0139.29
4.3.90.0470.0139.29
4.3.80.0630.0379.29
4.3.70.0470.0139.29
4.3.60.0500.0109.29
4.3.50.0670.0279.29
4.3.40.0630.0379.29
4.3.30.0270.0179.29
4.3.20.0230.0179.29
4.3.10.0370.0239.29
4.3.00.0170.0139.29

preferences:
49.03 ms | 400 KiB | 5 Q