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); #var_dump(MimeHalt::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, MimeHalt::$max_read_length, "\n\n"); if($line === false) return false; return $line . "\n"; } protected static function readNextBodyChunk($fh, $boundary) { $line = stream_get_line($fh, MimeHalt::$max_read_length, "\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.0100.01318.70
8.3.50.0110.00921.46
8.3.40.0080.00819.52
8.3.30.0040.01120.45
8.3.20.0040.00420.39
8.3.10.0040.00422.23
8.3.00.0050.00320.89
8.2.180.0060.00917.13
8.2.170.0090.00622.96
8.2.160.0070.00720.60
8.2.150.0070.01324.18
8.2.140.0170.00324.66
8.2.130.0070.00726.16
8.2.120.0060.00319.78
8.2.110.0030.00722.18
8.2.100.0080.00418.16
8.2.90.0000.00918.16
8.2.80.0040.00418.00
8.2.70.0000.00918.00
8.2.60.0090.00518.05
8.2.50.0000.00818.07
8.2.40.0040.00418.45
8.2.30.0000.00818.25
8.2.20.0000.00817.94
8.2.10.0080.00017.99
8.2.00.0000.01118.13
8.1.280.0070.01425.92
8.1.270.0080.00024.66
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0030.00622.59
8.1.230.0040.00821.09
8.1.220.0060.00317.79
8.1.210.0080.00018.97
8.1.200.0030.00617.72
8.1.190.0000.00817.76
8.1.180.0090.00019.21
8.1.170.0000.00918.76
8.1.160.0000.00722.15
8.1.150.0000.00818.84
8.1.140.0000.00817.70
8.1.130.0000.00717.91
8.1.120.0070.00017.64
8.1.110.0030.00517.68
8.1.100.0040.00417.57
8.1.90.0070.00017.57
8.1.80.0000.00717.73
8.1.70.0030.00317.69
8.1.60.0030.00617.85
8.1.50.0050.00317.81
8.1.40.0030.00517.76
8.1.30.0040.00417.84
8.1.20.0080.00017.83
8.1.10.0000.00817.79
8.1.00.0050.00517.80
8.0.300.0000.00820.15
8.0.290.0040.00417.43
8.0.280.0040.00418.65
8.0.270.0070.00017.37
8.0.260.0000.00717.20
8.0.250.0000.00817.27
8.0.240.0040.00417.34
8.0.230.0000.00817.23
8.0.220.0040.00417.23
8.0.210.0000.00717.17
8.0.200.0040.00417.38
8.0.190.0060.00317.38
8.0.180.0060.00317.14
8.0.170.0000.00817.29
8.0.160.0040.00417.33
8.0.150.0040.00417.24
8.0.140.0000.00717.12
8.0.130.0000.00613.80
8.0.120.0090.00017.22
8.0.110.0040.00417.34
8.0.100.0000.00817.07
8.0.90.0040.00417.27
8.0.80.0090.00917.27
8.0.70.0000.00717.34
8.0.60.0080.00017.21
8.0.50.0040.00417.09
8.0.30.0080.01117.23
8.0.20.0070.01217.40
8.0.10.0040.00417.30
8.0.00.0070.01317.13
7.4.330.0070.00015.00
7.4.320.0060.00016.83
7.4.300.0070.00016.97
7.4.290.0040.00416.95
7.4.280.0000.00716.82
7.4.270.0030.00316.87
7.4.260.0090.00016.86
7.4.250.0040.00416.88
7.4.240.0020.00516.83
7.4.230.0000.00716.68
7.4.220.0100.01916.77
7.4.210.0030.01116.89
7.4.200.0080.00016.86
7.4.190.0050.00217.07
7.4.160.0070.01016.74
7.4.150.0040.01217.40
7.4.140.0100.01017.86
7.4.130.0090.00916.85
7.4.120.0100.01116.78
7.4.110.0130.00716.91
7.4.100.0030.01616.80
7.4.90.0110.01516.70
7.4.80.0030.01419.39
7.4.70.0030.01316.64
7.4.60.0120.00616.76
7.4.50.0040.00016.90
7.4.40.0030.01422.77
7.4.30.0110.01116.80
7.4.00.0080.00715.28
7.3.330.0000.00513.69
7.3.320.0000.00513.80
7.3.310.0000.00816.78
7.3.300.0070.00016.71
7.3.290.0040.01016.77
7.3.280.0110.00616.70
7.3.270.0130.00717.40
7.3.260.0180.00716.90
7.3.250.0120.00716.79
7.3.240.0070.01016.76
7.3.230.0080.00916.76
7.3.210.0110.00716.75
7.3.200.0180.00419.39
7.3.190.0070.01516.70
7.3.180.0090.00616.87
7.3.170.0100.01016.68
7.3.160.0120.00816.90
7.3.120.0060.01115.26
7.3.110.0120.00615.22
7.3.100.0060.00915.32
7.3.90.0060.00915.38
7.3.80.0000.01415.13
7.3.70.0030.01015.15
7.3.60.0050.00515.28
7.3.50.0000.01215.02
7.3.40.0030.00715.19
7.3.30.0000.01415.00
7.3.20.0070.00716.77
7.3.10.0040.00716.75
7.3.00.0110.00816.93
7.2.330.0160.00316.88
7.2.320.0090.00916.94
7.2.310.0100.00717.05
7.2.300.0100.00716.94
7.2.290.0100.00717.06
7.2.250.0060.01215.57
7.2.240.0030.01715.49
7.2.230.0070.01315.40
7.2.220.0090.00315.31
7.2.210.0000.01015.59
7.2.200.0040.01215.37
7.2.190.0090.00615.42
7.2.180.0070.00715.52
7.2.170.0080.00415.21
7.2.130.0130.01017.16
7.2.120.0110.00717.27
7.2.110.0120.00317.09
7.2.100.0150.00316.93
7.2.90.0110.01116.88
7.2.80.0080.00816.84
7.2.70.0000.01716.81
7.2.60.0080.00817.12
7.2.50.0130.00716.82
7.2.40.0080.00817.04
7.2.30.0200.00317.25
7.2.20.0230.00317.13
7.2.10.0070.01517.25
7.2.00.0040.01116.97
7.1.330.0000.01416.05
7.1.320.0030.01216.03
7.1.310.0070.01016.30
7.1.300.0000.00915.96
7.1.290.0100.00316.12
7.1.280.0030.00615.82
7.1.270.0070.01116.05
7.1.260.0090.00915.88
7.1.250.0120.00616.00
7.1.200.0030.01016.11
7.1.70.0000.00817.21
7.1.60.0090.01519.21
7.1.50.0070.01817.29
7.1.00.0000.03722.34
7.0.200.0060.00615.15
7.0.140.0000.07722.09
7.0.110.0200.07320.05
7.0.100.0170.07020.18
7.0.90.0100.08719.99
7.0.80.0000.05320.02
7.0.70.0270.06020.01
7.0.60.0030.08320.18
7.0.50.0070.07720.04
7.0.40.0130.07319.74
7.0.30.0070.07719.84
7.0.20.0030.08319.65
7.0.10.0170.07319.82
7.0.00.0070.08019.74
5.6.280.0030.07321.14
5.6.260.0000.05320.95
5.6.250.0070.06720.71
5.6.240.0070.08020.91
5.6.230.0100.07720.59
5.6.220.0170.07020.63
5.6.210.0170.05720.77
5.6.200.0070.06720.67
5.6.190.0070.05320.66
5.6.180.0100.07320.76
5.6.170.0100.06720.70
5.6.160.0070.07320.59
5.6.150.0100.08320.91
5.6.140.0100.08020.67
5.6.130.0130.04320.66
5.6.120.0130.07320.90
5.6.110.0100.08020.66
5.6.100.0000.08020.69
5.6.90.0130.08020.73
5.6.80.0030.06720.02
5.6.70.0070.07720.01
5.6.60.0100.07020.28
5.6.50.0100.07320.03
5.6.40.0100.07319.98
5.6.30.0070.08020.02
5.6.20.0100.06720.00
5.6.10.0170.07019.97
5.6.00.0100.07720.03
5.5.380.0030.07717.73
5.5.370.0130.07317.60
5.5.360.0030.06017.58
5.5.350.0070.08017.55
5.5.340.0130.08018.16
5.5.330.0070.08017.94
5.5.320.0070.07318.00
5.5.310.0130.07318.09
5.5.300.0130.04318.11
5.5.290.0100.06017.98
5.5.280.0030.08018.09
5.5.270.0070.07718.15
5.5.260.0070.08318.05
5.5.250.0100.06717.80
5.5.240.0030.07717.65
5.5.230.0070.05717.32
5.5.220.0100.08017.54
5.5.210.0030.08317.54
5.5.200.0070.07317.30
5.5.190.0230.06317.62
5.5.180.0070.08017.46
5.5.160.0130.04717.48
5.5.150.0130.07017.59
5.5.140.0000.07317.34
5.5.130.0130.07017.61
5.5.120.0130.07017.51
5.5.110.0100.07317.57
5.5.100.0070.07717.19
5.5.90.0070.04317.49
5.5.80.0130.07017.41
5.5.70.0030.07717.13
5.5.60.0130.06717.47
5.5.50.0030.07717.18
5.5.40.0070.07317.48
5.5.30.0000.08017.23
5.5.20.0100.04317.18
5.5.10.0100.07017.17
5.5.00.0130.07017.34
5.4.450.0100.07319.35
5.4.440.0070.08019.32
5.4.430.0000.07719.28
5.4.420.0100.08019.34
5.4.410.0070.04719.45
5.4.400.0170.06719.24
5.4.390.0100.07719.36
5.4.380.0100.06719.02
5.4.370.0100.07018.96
5.4.360.0070.07319.06
5.4.350.0030.07319.24
5.4.340.0070.07019.23
5.4.320.0030.08319.19
5.4.310.0070.07319.04
5.4.300.0070.07719.16
5.4.290.0130.07319.01
5.4.280.0100.08019.09
5.4.270.0170.04019.04
5.4.260.0100.07319.01
5.4.250.0170.07019.01
5.4.240.0070.06719.00
5.4.230.0100.07019.16
5.4.220.0070.07019.24
5.4.210.0100.06719.04
5.4.200.0170.06719.07
5.4.190.0100.07019.02
5.4.180.0100.06319.02
5.4.170.0170.05018.98
5.4.160.0070.07719.05
5.4.150.0100.03319.00
5.4.140.0070.06316.43
5.4.130.0070.05016.34
5.4.120.0100.06716.46
5.4.110.0170.06316.63
5.4.100.0100.07016.47
5.4.90.0070.06716.48
5.4.80.0170.05716.41
5.4.70.0170.06016.60
5.4.60.0030.07716.54
5.4.50.0130.06716.60
5.4.40.0030.05016.44
5.4.30.0030.07716.44
5.4.20.0070.07016.44
5.4.10.0200.06316.62
5.4.00.0130.07315.81
5.3.290.0100.07314.97
5.3.280.0070.06714.69
5.3.270.0100.07714.82
5.3.260.0070.07314.80
5.3.250.0170.05314.63
5.3.240.0070.07714.68
5.3.230.0000.08714.81
5.3.220.0130.06014.73
5.3.210.0000.08314.78
5.3.200.0100.07314.64
5.3.190.0130.06314.79
5.3.180.0070.08014.66
5.3.170.0030.07714.79
5.3.160.0030.07714.73
5.3.150.0030.07714.64
5.3.140.0070.06714.74
5.3.130.0030.05014.65
5.3.120.0130.07014.64
5.3.110.0000.05314.71
5.3.100.0170.06713.97
5.3.90.0100.07713.94
5.3.80.0100.08013.85
5.3.70.0100.07313.94
5.3.60.0030.08713.91
5.3.50.0070.07313.89
5.3.40.0070.05713.81
5.3.30.0170.07013.84
5.3.20.0170.06713.53
5.3.10.0030.07313.57
5.3.00.0070.07713.49
5.2.170.0130.06010.97
5.2.160.0170.05711.07
5.2.150.0030.07310.97
5.2.140.0130.05710.98
5.2.130.0030.06711.05
5.2.120.0030.06711.05
5.2.110.0030.04311.05
5.2.100.0070.04011.05
5.2.90.0000.06711.09
5.2.80.0030.06311.05
5.2.70.0030.07311.05
5.2.60.0070.06011.05
5.2.50.0130.05711.05
5.2.40.0170.02711.05
5.2.30.0130.05711.05
5.2.20.0130.05711.05
5.2.10.0030.06711.05
5.2.00.0100.06311.05
5.1.60.0030.05311.05
5.1.50.0070.03011.05
5.1.40.0000.03011.05
5.1.30.0030.02711.05
5.1.20.0100.03011.05
5.1.10.0000.02711.05
5.1.00.0030.03311.05
5.0.50.0030.02011.05
5.0.40.0000.02011.05
5.0.30.0000.03011.05
5.0.20.0030.02011.05
5.0.10.0000.02311.05
5.0.00.0030.02711.05
4.4.90.0030.02011.05
4.4.80.0030.02011.05
4.4.70.0000.02711.05
4.4.60.0030.01711.05
4.4.50.0000.02311.05
4.4.40.0070.04711.05
4.4.30.0030.01311.05
4.4.20.0030.01711.05
4.4.10.0000.01711.05
4.4.00.0030.02311.05
4.3.110.0000.01711.05
4.3.100.0000.01311.05
4.3.90.0000.02011.05
4.3.80.0070.02011.05
4.3.70.0070.00711.05
4.3.60.0030.01311.05
4.3.50.0000.01711.05
4.3.40.0000.02711.05
4.3.30.0000.01711.05
4.3.20.0000.01711.05
4.3.10.0000.02311.05
4.3.00.0000.01311.05

preferences:
39.78 ms | 401 KiB | 5 Q