3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ERROR); $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.60.0160.00616.73
8.3.50.0090.00917.02
8.3.40.0100.00719.10
8.3.30.0110.00419.05
8.3.20.0090.00019.07
8.3.10.0060.00320.83
8.3.00.0060.00319.63
8.2.180.0080.00817.00
8.2.170.0060.01022.96
8.2.160.0060.01019.34
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00019.31
8.2.110.0070.00320.55
8.2.100.0080.00418.16
8.2.90.0080.00018.00
8.2.80.0000.01017.97
8.2.70.0100.00018.05
8.2.60.0050.00518.29
8.2.50.0000.00818.16
8.2.40.0080.00320.72
8.2.30.0030.00518.24
8.2.20.0030.00618.14
8.2.10.0040.00417.95
8.2.00.0000.00817.99
8.1.280.0070.00725.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0000.01022.10
8.1.230.0110.00022.26
8.1.220.0040.00417.77
8.1.210.0060.00318.77
8.1.200.0000.00917.47
8.1.190.0060.00317.61
8.1.180.0050.00518.10
8.1.170.0030.00618.76
8.1.160.0030.00518.91
8.1.150.0030.00518.89
8.1.140.0040.00417.71
8.1.130.0040.00417.95
8.1.120.0030.00617.71
8.1.110.0070.00017.74
8.1.100.0040.00417.59
8.1.90.0040.00417.79
8.1.80.0050.00217.73
8.1.70.0000.00717.65
8.1.60.0000.00817.88
8.1.50.0080.00017.73
8.1.40.0000.00817.67
8.1.30.0030.00517.75
8.1.20.0060.00317.92
8.1.10.0040.00417.88
8.1.00.0040.00417.72
8.0.300.0000.00919.93
8.0.290.0030.00616.98
8.0.280.0040.00418.57
8.0.270.0000.00717.46
8.0.260.0070.00017.24
8.0.250.0050.00317.33
8.0.240.0080.00017.34
8.0.230.0000.00817.31
8.0.220.0000.00717.31
8.0.210.0080.00017.27
8.0.200.0000.00717.21
8.0.190.0040.00417.35
8.0.180.0000.00817.33
8.0.170.0030.00617.29
8.0.160.0030.00617.34
8.0.150.0030.00617.13
8.0.140.0000.01117.23
8.0.130.0000.00613.73
8.0.120.0000.00717.21
8.0.110.0080.00017.15
8.0.100.0000.00817.27
8.0.90.0070.00017.07
8.0.80.0100.00517.22
8.0.70.0030.00517.07
8.0.60.0030.00617.09
8.0.50.0050.00317.25
8.0.30.0080.01117.54
8.0.20.0080.01217.46
8.0.10.0040.00417.44
8.0.00.0100.01317.15
7.4.330.0000.00513.22
7.4.320.0030.00316.96
7.4.300.0000.00616.86
7.4.290.0070.00016.68
7.4.280.0060.00316.91
7.4.270.0000.00816.93
7.4.260.0040.00413.57
7.4.250.0000.00916.91
7.4.240.0000.01016.84
7.4.230.0070.00016.93
7.4.220.0100.01316.86
7.4.210.0070.00916.91
7.4.200.0000.00716.92
7.4.190.0040.00416.96
7.4.160.0100.00716.77
7.4.150.0150.00916.94
7.4.140.0110.01216.97
7.4.130.0060.01316.94
7.4.120.0120.00717.02
7.4.110.0110.00717.10
7.4.100.0120.01216.76
7.4.90.0120.01416.82
7.4.80.0160.00719.39
7.4.70.0070.01116.91
7.4.60.0030.01316.83
7.4.50.0110.00417.02
7.4.40.0030.01316.78
7.4.30.0110.00616.71
7.4.00.0060.01315.22
7.3.330.0000.00713.72
7.3.320.0030.00313.75
7.3.310.0070.00016.77
7.3.300.0000.00716.73
7.3.290.0070.01016.81
7.3.280.0070.00916.73
7.3.270.0100.00816.77
7.3.260.0170.00316.86
7.3.250.0130.00816.85
7.3.240.0040.01416.64
7.3.230.0070.01116.70
7.3.210.0080.01616.67
7.3.200.0100.00916.95
7.3.190.0120.00616.97
7.3.180.0090.00616.75
7.3.170.0000.01716.83
7.3.160.0100.00716.79
7.3.120.0080.00915.18
7.3.110.0070.01115.15
7.3.100.0110.00414.88
7.3.90.0050.00514.98
7.3.80.0110.00715.24
7.3.70.0000.01515.25
7.3.60.0070.01014.96
7.3.50.0000.01315.14
7.3.40.0030.00915.10
7.3.30.0070.00715.08
7.3.20.0090.00616.97
7.3.10.0030.00816.88
7.3.00.0050.00816.62
7.2.330.0130.01317.01
7.2.320.0100.01017.11
7.2.310.0060.01316.89
7.2.300.0170.00317.05
7.2.290.0150.00616.88
7.2.250.0140.00715.11
7.2.240.0040.01615.40
7.2.230.0000.01415.36
7.2.220.0110.00415.55
7.2.210.0060.00615.40
7.2.200.0040.01415.41
7.2.190.0000.01415.25
7.2.180.0040.01115.54
7.2.170.0070.00715.27
7.2.130.0040.00717.10
7.2.120.0100.00516.98
7.2.110.0070.00416.75
7.2.100.0080.00816.98
7.2.90.0000.01316.54
7.2.80.0100.00316.93
7.2.70.0030.01516.90
7.2.60.0090.00617.07
7.2.50.0140.00417.01
7.2.40.0190.00417.07
7.2.30.0160.00317.11
7.2.20.0110.01416.83
7.2.10.0090.00617.03
7.2.00.0070.00518.47
7.1.330.0070.00715.88
7.1.320.0140.00016.03
7.1.310.0060.00916.26
7.1.300.0060.00615.99
7.1.290.0030.00616.04
7.1.280.0070.00715.69
7.1.270.0000.01416.07
7.1.260.0070.00715.93
7.1.250.0120.00315.77
7.1.100.0030.00718.52
7.1.70.0040.01117.41
7.1.60.0070.02019.40
7.1.50.0130.01017.36
7.1.00.0000.05322.36
7.0.200.0070.00715.25
7.0.140.0000.07722.21
7.0.120.0000.07322.19
7.0.100.0430.07320.08
7.0.90.0370.08719.99
7.0.80.0600.07719.97
7.0.70.0630.07720.00
7.0.60.0530.08320.04
7.0.50.0470.07720.36
7.0.40.0130.07320.11
7.0.30.0070.08320.19
7.0.20.0200.03320.04
7.0.10.0200.06320.00
7.0.00.0130.07720.10
5.6.280.0000.07721.18
5.6.250.0070.08020.65
5.6.240.0100.07720.70
5.6.230.0100.08320.55
5.6.220.0070.07320.73
5.6.210.0030.09320.71
5.6.200.0070.05021.13
5.6.190.0100.04721.13
5.6.180.0170.08321.12
5.6.170.0030.05021.06
5.6.160.0100.04021.02
5.6.150.0030.04321.19
5.6.140.0130.07721.07
5.6.130.0030.09321.16
5.6.120.0000.04721.19
5.6.110.0000.04721.09
5.6.100.0100.04321.08
5.6.90.0100.03720.97
5.6.80.0070.04020.39
5.6.70.0100.04320.38
5.6.60.0070.05320.38
5.6.50.0000.04020.38
5.6.40.0070.04020.43
5.6.30.0070.04020.35
5.6.20.0030.04020.45
5.6.10.0030.04020.52
5.6.00.0000.04320.38
5.5.380.0070.08320.60
5.5.370.0070.07720.50
5.5.360.0170.07720.43
5.5.350.0100.08020.45
5.5.340.0000.08720.89
5.5.330.0100.04320.83
5.5.320.0200.03720.97
5.5.310.0100.05320.98
5.5.300.0070.05020.92
5.5.290.0070.05320.88
5.5.280.0100.04720.94
5.5.270.0030.04320.88
5.5.260.0170.03320.93
5.5.250.0130.04020.64
5.5.240.0100.03720.27
5.5.230.0030.04020.07
5.5.220.0070.03720.03
5.5.210.0000.04020.32
5.5.200.0000.04320.34
5.5.190.0100.03320.19
5.5.180.0030.04020.32
5.5.160.0130.06020.30
5.5.150.0100.03720.27
5.5.140.0030.04020.00
5.5.130.0100.03320.23
5.5.120.0130.03020.32
5.5.110.0100.03320.27
5.5.100.0000.05020.23
5.5.90.0070.03720.16
5.5.80.0070.04020.15
5.5.70.0030.04019.97
5.5.60.0000.04020.05
5.5.50.0030.05320.02
5.5.40.0130.03020.05
5.5.30.0070.03720.20
5.5.20.0030.04020.11
5.5.10.0000.04320.09
5.5.00.0000.04320.14
5.4.450.0100.03719.47
5.4.440.0100.03319.48
5.4.430.0070.05319.21
5.4.420.0100.03319.21
5.4.410.0100.03319.36
5.4.400.0030.03719.20
5.4.390.0070.04019.04
5.4.380.0070.05719.22
5.4.370.0130.04719.07
5.4.360.0030.04018.89
5.4.350.0000.06019.05
5.4.340.0030.04719.10
5.4.320.0100.04018.92
5.4.310.0070.03718.89
5.4.300.0200.04319.04
5.4.290.0000.04018.86
5.4.280.0070.03719.04
5.4.270.0030.03719.10
5.4.260.0100.03019.13
5.4.250.0000.07318.88
5.4.240.0030.04719.16
5.4.230.0130.03018.88
5.4.220.0030.03719.04
5.4.210.0100.03019.17
5.4.200.0000.04019.05
5.4.190.0030.03719.16
5.4.180.0070.03319.03
5.4.170.0030.04719.09
5.4.160.0100.03718.89
5.4.150.0130.03018.84
5.4.140.0030.07716.49
5.4.130.0030.07016.49
5.4.120.0100.04016.39
5.4.110.0100.07016.56
5.4.100.0170.06316.50
5.4.90.0070.06716.48
5.4.80.0100.06016.32
5.4.70.0130.06716.54
5.4.60.0100.06716.31
5.4.50.0170.06016.38
5.4.40.0030.07716.42
5.4.30.0070.06716.41
5.4.20.0070.07316.44
5.4.10.0030.05716.50
5.4.00.8971.60315.80
5.3.290.0100.05014.84
5.3.280.0000.04314.68
5.3.270.0100.03014.81
5.3.260.0030.04014.65
5.3.250.0030.04014.79
5.3.240.0030.07014.67
5.3.230.0030.07714.64
5.3.220.0070.05714.71
5.3.210.0170.06714.75
5.3.200.0000.07714.78
5.3.190.0100.07014.74
5.3.180.0100.06314.57
5.3.170.0030.07714.76
5.3.160.0100.07014.60
5.3.150.0070.07314.71
5.3.140.0030.05314.63
5.3.130.0070.07014.69
5.3.120.0170.07014.69
5.3.110.0070.07014.64
5.3.100.7531.74713.94
5.3.90.8731.62713.86
5.3.80.8001.70014.01
5.3.70.7301.77013.83
5.3.60.7571.74313.89
5.3.50.8071.69313.77
5.3.40.7901.71013.84
5.3.30.7771.72313.74
5.3.20.8331.66713.55
5.3.10.8301.67013.64
5.3.00.7601.74013.42
5.2.170.7031.79711.07
5.2.160.6831.81711.02
5.2.150.5671.93311.12
5.2.140.7131.78711.09
5.2.130.5831.91711.00
5.2.120.6801.82010.93
5.2.110.6001.90011.01
5.2.100.6701.83011.00
5.2.90.6531.84710.80
5.2.80.7271.77310.87
5.2.70.6831.81710.89
5.2.60.6001.90010.86
5.2.50.8901.60710.77
5.2.40.6771.82310.83
5.2.30.0072.49310.82
5.2.20.0032.49711.01
5.2.10.0032.49710.83
5.2.00.6471.85310.45
5.1.60.0030.05310.24
5.1.50.0030.03010.24
5.1.40.0130.04710.24
5.1.30.0030.06310.51
5.1.20.0030.04310.45
5.1.10.0100.05010.24
5.1.00.0070.05310.24
5.0.50.0030.04710.24
5.0.40.0030.02310.24
5.0.30.0030.06310.24
5.0.20.0070.02710.24
5.0.10.0030.04710.24
5.0.00.0130.05310.24
4.4.90.0030.01310.24
4.4.80.0070.02710.24
4.4.70.0000.03710.24
4.4.60.0000.03710.24
4.4.50.0000.02710.24
4.4.40.0000.04010.24
4.4.30.0100.03010.24
4.4.20.0000.02310.24
4.4.10.0030.01710.24
4.4.00.0070.05010.24
4.3.110.0030.03710.24
4.3.100.0030.03310.24
4.3.90.0000.03710.24
4.3.80.0030.05310.24
4.3.70.0030.02010.24
4.3.60.0030.03010.24
4.3.50.0030.03710.24
4.3.40.0030.04310.24
4.3.30.0000.02010.24
4.3.20.0000.03710.24
4.3.10.0030.03710.24
4.3.00.0000.03710.24

preferences:
43.83 ms | 401 KiB | 5 Q