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 static $max_read_length = 1048577; 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, MimeHalt::$max_read_length, "\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); 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); $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() { 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); $this->config['offset_map'][$headers['Content-ID']] = ftell($this->fh); MimeHalt::readNextBodyChunk($this->fh, $this->mime_boundary); } } 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, MimeHalt::$max_read_length, "\n\n"); if($line === false) return false; return $line . "\n"; } protected static function readNextBodyChunk($fh, $boundary) { $line = rtrim(stream_get_line($fh, MimeHalt::$max_read_length, "\n" . $boundary . "\n")); $end_of_body_string = "\n" . $boundary . "--"; $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!"; var_dump(debug_backtrace()); --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.0150.00618.56
8.3.50.0090.00721.33
8.3.40.0120.00319.02
8.3.30.0040.01120.33
8.3.20.0050.00320.52
8.3.10.0060.00321.91
8.3.00.0040.00420.81
8.2.180.0100.01017.13
8.2.170.0080.00822.96
8.2.160.0140.00020.70
8.2.150.0050.00324.18
8.2.140.0100.01024.66
8.2.130.0040.00426.16
8.2.120.0040.00419.78
8.2.110.0060.00320.47
8.2.100.0110.00318.09
8.2.90.0030.00618.09
8.2.80.0030.00718.00
8.2.70.0050.00318.15
8.2.60.0030.00618.34
8.2.50.0050.00318.10
8.2.40.0040.00419.47
8.2.30.0040.00419.47
8.2.20.0040.00418.16
8.2.10.0050.00318.19
8.2.00.0060.00617.96
8.1.280.0160.00625.92
8.1.270.0040.00424.66
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0100.00022.58
8.1.230.0040.00822.73
8.1.220.0050.00317.91
8.1.210.0070.00318.77
8.1.200.0090.00317.48
8.1.190.0030.00617.61
8.1.180.0050.00318.10
8.1.170.0060.00318.88
8.1.160.0040.00419.15
8.1.150.0050.00318.88
8.1.140.0030.00617.74
8.1.130.0070.00017.82
8.1.120.0040.00417.79
8.1.110.0050.00317.69
8.1.100.0000.00717.78
8.1.90.0040.00417.82
8.1.80.0030.00617.71
8.1.70.0030.00317.76
8.1.60.0060.00617.68
8.1.50.0030.00617.69
8.1.40.0040.00417.72
8.1.30.0040.00417.86
8.1.20.0030.00617.83
8.1.10.0040.00417.90
8.1.00.0040.00717.77
8.0.300.0000.00820.23
8.0.290.0040.00417.00
8.0.280.0020.00518.62
8.0.270.0070.00017.46
8.0.260.0000.00817.09
8.0.250.0000.00717.36
8.0.240.0040.00417.39
8.0.230.0050.00217.36
8.0.220.0000.00717.19
8.0.210.0050.00317.20
8.0.200.0000.00717.31
8.0.190.0030.00517.25
8.0.180.0000.00817.32
8.0.170.0040.00417.35
8.0.160.0040.00417.18
8.0.150.0040.00417.32
8.0.140.0040.00417.26
8.0.130.0000.00613.67
8.0.120.0080.00017.14
8.0.110.0000.00817.13
8.0.100.0050.00317.23
8.0.90.0030.00617.23
8.0.80.0100.00717.27
8.0.70.0000.00817.25
8.0.60.0030.00517.35
8.0.50.0020.00517.34
8.0.30.0070.01317.45
8.0.20.0100.01017.42
8.0.10.0000.00817.28
8.0.00.0070.01117.04
7.4.330.0070.00015.00
7.4.320.0000.00716.85
7.4.300.0030.00316.77
7.4.290.0040.00416.82
7.4.280.0040.00416.91
7.4.270.0030.00316.91
7.4.260.0000.00816.83
7.4.250.0040.00416.79
7.4.240.0000.00816.93
7.4.230.0050.00216.85
7.4.220.0100.01016.98
7.4.210.0110.00516.91
7.4.200.0040.00416.72
7.4.190.0040.00416.98
7.4.160.0080.00816.88
7.4.150.0100.01017.40
7.4.140.0090.00917.86
7.4.130.0060.01116.99
7.4.120.0100.00816.84
7.4.110.0040.01416.86
7.4.100.0150.00316.82
7.4.90.0110.00716.87
7.4.80.0140.01019.39
7.4.70.0090.00816.87
7.4.60.0060.01216.99
7.4.50.0060.00016.95
7.4.40.0040.01522.77
7.4.30.0050.01816.88
7.4.00.0060.01015.10
7.3.330.0000.00513.82
7.3.320.0000.00613.53
7.3.310.0050.00216.75
7.3.300.0000.00716.62
7.3.290.0100.01016.67
7.3.280.0100.00716.77
7.3.270.0130.00517.40
7.3.260.0210.00016.91
7.3.250.0150.00516.68
7.3.240.0110.01416.70
7.3.230.0070.01116.77
7.3.210.0110.00716.82
7.3.200.0150.00619.39
7.3.190.0090.00916.83
7.3.180.0090.00916.72
7.3.170.0120.00916.66
7.3.160.0090.00916.74
7.3.120.0080.00815.35
7.2.330.0140.00317.10
7.2.320.0040.01517.04
7.2.310.0100.01317.09
7.2.300.0040.01316.79
7.2.290.0060.01117.05
7.2.00.0030.01019.78
7.1.200.0030.01215.77
7.1.100.0040.00818.18
7.1.70.0030.00517.51
7.1.60.0100.01619.21
7.1.50.0120.00617.31
7.1.00.0000.03722.54
7.0.200.0160.00315.28
7.0.140.0030.07322.02
7.0.70.5030.03719.99
7.0.60.0100.05319.97
7.0.50.0030.07717.98
7.0.40.0100.04320.11
7.0.30.0270.07320.13
7.0.20.0230.05720.17
7.0.10.0330.05020.11
7.0.00.0000.05320.39
5.6.280.0030.07321.14
5.6.210.0100.05720.75
5.6.200.0070.08318.18
5.6.190.0030.05320.46
5.6.180.0170.08020.37
5.6.170.0230.06020.51
5.6.160.0030.08020.62
5.6.150.0030.04318.32
5.6.140.0070.04318.29
5.6.130.0130.06318.32
5.6.120.0070.05320.95
5.6.110.0130.06321.15
5.6.100.0030.04721.00
5.6.90.0100.08021.05
5.6.80.0070.07720.46
5.6.70.0100.07720.53
5.5.350.0000.08720.46
5.5.340.0030.04018.08
5.5.330.0100.06020.20
5.5.320.0070.08020.58
5.5.310.0270.08020.38
5.5.300.0070.08017.99
5.5.290.0030.07718.02
5.5.280.0070.05020.95
5.5.270.0070.04720.94
5.5.260.0130.08320.81
5.5.250.0100.08320.71
5.5.240.0200.07020.34
5.4.450.1800.04019.21
5.4.440.2400.03719.49
5.4.430.2070.05319.32
5.4.420.2100.04319.49
5.4.410.1730.04319.36
5.4.400.1870.03318.87
5.4.390.1800.03719.17
5.4.380.1870.03019.09
5.4.370.2300.03319.13
5.4.360.2030.04319.27
5.4.350.2000.05019.21
5.4.340.2200.04319.14
5.4.320.1830.03718.85
5.4.310.2100.05018.88
5.4.300.0700.04319.13
5.4.290.0070.07319.07
5.4.280.0070.07019.13
5.4.270.1470.04718.95
5.4.260.2130.03318.92
5.4.250.1830.04319.20
5.4.240.2070.04719.17
5.4.230.2130.04019.06
5.4.220.1870.03719.06
5.4.210.2070.04719.09
5.4.200.2070.04019.14
5.4.190.2230.04019.31
5.4.180.2070.04319.06
5.4.170.2100.04019.24
5.4.160.1870.03319.08
5.4.150.1800.04718.91
5.4.140.2100.04716.52
5.4.130.2070.04016.36
5.4.120.1870.03716.57
5.4.110.1830.03716.25
5.4.100.1900.03016.62
5.4.90.1800.03716.61
5.4.80.1830.03316.46
5.4.70.1800.03716.29
5.4.60.1600.03316.57
5.4.50.0070.03316.43
5.4.40.0030.03716.54
5.4.30.1530.03016.21
5.4.20.1800.04016.48
5.4.10.1870.03716.58
5.4.00.1930.03015.83
5.3.290.2070.04314.70
5.3.280.2030.05314.63
5.3.270.2200.04014.68
5.3.260.2230.04014.76
5.3.250.1900.03714.64
5.3.240.1470.03714.57
5.3.230.0000.09014.66
5.3.220.0130.05014.62
5.3.210.1370.04714.66
5.3.200.1930.04314.62
5.3.190.2070.04014.54
5.3.180.1930.04314.66
5.3.170.2000.04314.65
5.3.160.1970.03714.79
5.3.150.1730.04014.86
5.3.140.1930.03714.64
5.3.130.2070.04714.53
5.3.120.2000.04714.55
5.3.110.2070.04014.74
5.3.100.0070.04314.18
5.3.90.0100.03313.93
5.3.80.0970.06013.79
5.3.70.1930.03313.85
5.3.60.1730.04313.77
5.3.50.1770.04013.88
5.3.40.1770.03713.84
5.3.30.2070.04713.84
5.3.20.1630.03713.45
5.3.10.1800.03313.58
5.3.00.2000.04013.57
5.2.170.0100.05011.02
5.2.160.0170.05011.15
5.2.150.0200.04011.15
5.2.140.0170.04711.04
5.2.130.0130.04710.98
5.2.120.0100.04710.98
5.2.110.0070.05311.00
5.2.100.0200.03711.00
5.2.90.0130.05011.02
5.2.80.0130.05010.98
5.2.70.0130.05011.05
5.2.60.0130.04310.92
5.2.50.0200.05310.90
5.2.40.0170.03710.88
5.2.30.0100.06010.86
5.2.20.0100.04710.80
5.2.10.0100.04310.80
5.2.00.0000.07310.77
5.1.60.0000.02710.07
5.1.50.0130.02710.20
5.1.40.1170.0239.94
5.1.30.1200.02310.55
5.1.20.1270.03710.50
5.1.10.0030.02310.14
5.1.00.0030.02310.37
5.0.50.0000.0339.68
5.0.40.0000.0279.68
5.0.30.0070.0279.68
5.0.20.0070.0409.68
5.0.10.0000.0279.68
5.0.00.0000.0339.68
4.4.90.0370.0139.68
4.4.80.0730.0139.68
4.4.70.0630.0139.68
4.4.60.0630.0139.68
4.4.50.0600.0179.68
4.4.40.0600.0239.68
4.4.30.0600.0139.68
4.4.20.0600.0139.68
4.4.10.0600.0139.68
4.4.00.0600.0239.68
4.3.110.0570.0179.68
4.3.100.0570.0209.68
4.3.90.0630.0179.68
4.3.80.0670.0239.68
4.3.70.0570.0179.68
4.3.60.0800.0109.68
4.3.50.0570.0179.68
4.3.40.0630.0239.68
4.3.30.0330.0179.68
4.3.20.0300.0179.68
4.3.10.0330.0139.68
4.3.00.0330.0139.68

preferences:
39.06 ms | 401 KiB | 5 Q