3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Minecraft Server Status Class * @copyright © 2011 Nox Nebula - Patrick Kleinschmidt * @website https://github.com/NoxNebula/MC-Server-Status * @license GNU Public Licence - Version 3 * @author Nox Nebula - Patrick Kleinschmidt * @author Alexey Kachalov **/ class ms { private $Socket, $Info, $to; public $Online, $MOTD, $CurPlayers, $MaxPlayers, $IP, $Port, $Error; public function __construct($IP, $Port = '25565', $timeout='0.5') { $this->IP = $IP; $this->Port = $Port; $this->to = $timeout; // Remove any protocols from serveraddress if(preg_match('/(.*):\/\//', $this->IP)) { $this->IP = preg_replace('/(.*):\/\//', '', $this->IP); } if(strpos($this->IP, '/') !== false) { $this->IP = rtrim($this->IP, '/'); if(strpos($this->IP, '/') !== false) { $this->Failed(); $this->Error = 'Unsupported IP/Domain format, no \'/\'s allowed'; return; } } if(preg_match_all('/:/', $this->IP, $matches) > 1) { unset($matches); // IP6 if(strpos($this->IP, '[') === false && strpos($this->IP, ']') === false) $this->IP = '['.$this->IP.']'; } else if(strpos($this->IP, ':') !== false) { $this->Failed(); $this->Error = 'Unsupported IP/Domain format'; return; } if($this->Socket = @stream_socket_client('tcp://'.$this->IP.':'.$Port, $ErrNo, $ErrStr, $this->to)) { // If IP6 remove brackets if(strpos($this->IP, '[') === 0 && strpos($this->IP, ']') === (strlen($this->IP) - 1)) $this->IP = trim($this->IP, '[]'); $this->Online = true; fwrite($this->Socket, "\xfe"); $Handle = fread($this->Socket, 2048); //$Handle = str_replace("\x00", '', $Handle); //$Handle = substr($Handle, 2); //$this->Info = explode("\xa7", $Handle); // Separate Infos /*if(sizeof($this->Info) == 3) { $this->MOTD = $this->Info[0]; $this->CurPlayers = (int)$this->Info[1]; $this->MaxPlayers = (int)$this->Info[2]; $this->Error = false; } else if(sizeof($this->Info) > 3) { // Handle error, Minecraft don't handle this. $Temp = ''; for($i = 0; $i < sizeof($this->Info) - 2; $i++) { $Temp .= ($i > 0 ? '§' : '').$this->Info[$i]; } $this->MOTD = $Temp; $this->CurPlayers = (int)$this->Info[sizeof($this->Info) - 2]; $this->MaxPlayers = (int)$this->Info[sizeof($this->Info) - 1]; $this->Error = 'Faulty motd or outdated script'; } else { $this->Failed(); $this->Error = 'Unexpected error, cause may be an outdated script'; }*/ $Handle = substr($Handle, 1); if(strpos($Handle, "\x00\x00")!=0) { $Handle = explode("\x00\x00", $Handle); $Handle = str_replace("\x00", '', $Handle); $this->MOTD = $Handle[3]; $this->CurPlayers = $Handle[4]; $this->MaxPlayers = $Handle[5]; $this->Error = false; } else { $Handle = explode("\xa7", $Handle); $Handle = str_replace("\x00", '', $Handle); $this->MOTD = $Handle[0]; $this->CurPlayers = $Handle[1]; $this->MaxPlayers = $Handle[2]; $this->Error = false; } unset($Handle); fclose($this->Socket); } else { $this->Online = false; $this->Failed(); $this->Error = 'Can not reach the server'; } } public function Info() { return array( 'MOTD' => $this->MOTD, 'CurPlayers' => $this->CurPlayers, 'MaxPlayers' => $this->MaxPlayers ); } private function Failed() { $this->MOTD = false; $this->CurPlayers = false; $this->MaxPlayers = false; } } ?>

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.0090.00618.33
8.3.50.0140.00621.27
8.3.40.0000.01418.54
8.3.30.0080.00818.59
8.3.20.0080.00018.60
8.3.10.0090.00020.43
8.3.00.0060.00319.25
8.2.180.0070.01416.38
8.2.170.0070.00722.96
8.2.160.0080.00622.21
8.2.150.0000.00824.18
8.2.140.0050.00224.66
8.2.130.0080.00026.16
8.2.120.0040.00419.70
8.2.110.0000.00921.03
8.2.100.0060.00617.87
8.2.90.0030.00519.23
8.2.80.0000.00817.97
8.2.70.0030.00617.50
8.2.60.0040.00417.93
8.2.50.0050.00318.07
8.2.40.0000.00818.16
8.2.30.0060.00618.00
8.2.20.0000.00717.67
8.2.10.0040.00417.69
8.2.00.0000.00817.68
8.1.280.0110.00425.92
8.1.270.0040.00423.99
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0060.00322.54
8.1.230.0000.01120.87
8.1.220.0060.00318.77
8.1.210.0000.00819.10
8.1.200.0050.00517.23
8.1.190.0000.00717.52
8.1.180.0000.00918.10
8.1.170.0060.00318.91
8.1.160.0070.00018.91
8.1.150.0030.00618.47
8.1.140.0000.00817.39
8.1.130.0030.00317.87
8.1.120.0070.00017.51
8.1.110.0000.00817.42
8.1.100.0040.00417.49
8.1.90.0040.00417.48
8.1.80.0080.00017.43
8.1.70.0030.00317.31
8.1.60.0050.00317.58
8.1.50.0060.00317.43
8.1.40.0000.00817.48
8.1.30.0000.00717.66
8.1.20.0040.00417.66
8.1.10.0000.00817.39
8.1.00.0000.00817.41
8.0.300.0050.00519.91
8.0.290.0070.00016.88
8.0.280.0030.00318.34
8.0.270.0050.00317.17
8.0.260.0030.00316.72
8.0.250.0000.00716.80
8.0.240.0000.00716.91
8.0.230.0030.00516.90
8.0.220.0000.01016.87
8.0.210.0020.00516.90
8.0.200.0060.00416.83
8.0.190.0070.00016.91
8.0.180.0000.00716.88
8.0.170.0030.00616.81
8.0.160.0000.00716.98
8.0.150.0040.00416.91
8.0.140.0080.00016.75
8.0.130.0000.00513.35
8.0.120.0040.00416.84
8.0.110.0050.00316.70
8.0.100.0050.00216.72
8.0.90.0050.00216.68
8.0.80.0090.00616.80
8.0.70.0050.00216.68
8.0.60.0050.00216.99
8.0.50.0000.00716.85
8.0.30.0140.00517.07
8.0.20.0100.01017.40
8.0.10.0040.00417.07
8.0.00.0120.00816.77
7.4.330.0020.00213.43
7.4.320.0070.00016.39
7.4.300.0000.00716.59
7.4.290.0060.00016.47
7.4.280.0040.00416.50
7.4.270.0040.00416.40
7.4.260.0050.00013.21
7.4.250.0000.00816.57
7.4.240.0040.00416.38
7.4.230.0050.00216.56
7.4.220.0060.01916.43
7.4.210.0080.00916.54
7.4.200.0000.00716.38
7.4.190.0000.00716.53
7.4.160.0070.00916.42
7.4.150.0150.00317.40
7.4.140.0090.00817.12
7.4.130.0110.00616.42
7.4.120.0080.00816.41
7.4.110.0110.01116.60
7.4.100.0090.00916.60
7.4.90.0130.01016.45
7.4.80.0100.01019.03
7.4.70.0070.01416.42
7.4.60.0120.00616.50
7.4.50.0060.00316.57
7.4.40.0040.01122.27
7.4.30.0100.00516.59
7.4.00.0120.00014.79
7.3.330.0050.00013.13
7.3.320.0030.00313.24
7.3.310.0070.00016.32
7.3.300.0000.00716.33
7.3.290.0120.00316.29
7.3.280.0070.00816.27
7.3.270.0170.00017.40
7.3.260.0130.00518.24
7.3.250.0090.01316.31
7.3.240.0100.01016.28
7.3.230.0090.00916.39
7.3.210.0090.00916.54
7.3.200.0180.00319.39
7.3.190.0090.01016.48
7.3.180.0110.00616.28
7.3.170.0060.01016.30
7.3.160.0150.00316.49
7.3.120.0060.01014.61
7.2.330.0180.00016.68
7.2.320.0060.01516.42
7.2.310.0160.00716.64
7.2.300.0110.01116.34
7.2.290.0100.01316.44
7.1.70.0000.00816.94
7.1.60.0100.01419.40
7.1.50.0070.01016.88
7.1.00.0070.06722.54
7.0.200.0190.01014.59
7.0.140.0000.07722.14
7.0.60.0030.07721.72
7.0.50.0070.08317.80
7.0.40.0100.04317.72
7.0.30.0070.05017.80
7.0.20.0030.08717.71
7.0.10.0100.03717.85
7.0.00.0070.06317.75
5.6.280.0030.07721.10
5.6.210.0070.08020.75
5.6.200.0070.07718.29
5.6.190.0000.05718.18
5.6.180.0100.08318.25
5.6.170.0000.05318.21
5.6.160.0070.05018.19
5.6.150.0070.05018.19
5.6.140.0100.07318.28
5.6.130.0130.05318.16
5.6.120.0030.08718.21
5.6.110.0130.05018.18
5.6.100.0100.04718.20
5.6.90.0030.06018.17
5.6.80.0070.07717.67
5.6.70.0070.08317.60
5.6.60.0030.05017.55
5.6.50.0070.07017.57
5.6.40.0130.05317.64
5.6.30.0200.06317.61
5.6.20.0030.05717.64
5.6.10.0100.05017.54
5.6.00.0000.04317.59
5.5.350.0070.08020.43
5.5.340.0070.08317.95
5.5.330.0000.07317.97
5.5.320.0000.04718.02
5.5.310.0200.07318.01
5.5.300.0070.07717.96
5.5.290.0000.05318.01
5.5.280.0130.08017.95
5.5.270.0030.06318.07
5.5.260.0070.06718.04
5.5.250.0130.06317.87
5.5.240.0130.07017.37
5.5.230.0100.07317.47
5.5.220.0030.04017.32
5.5.210.0100.07317.43
5.5.200.0070.07717.43
5.5.190.0030.04017.34
5.5.180.0100.03317.39
5.5.160.0070.03717.40
5.5.150.0170.05717.30
5.5.140.0000.05317.39
5.5.130.0030.05017.34
5.5.120.0130.06017.29
5.5.110.0070.03717.43
5.5.100.0030.03717.20
5.5.90.0000.04017.24
5.5.80.0000.04017.21
5.5.70.0030.03717.21
5.5.60.0000.03717.30
5.5.50.0030.03717.29
5.5.40.0000.04017.38
5.5.30.0030.03717.18
5.5.20.0000.04017.30
5.5.10.0070.03317.21
5.5.00.0100.03317.24
5.4.450.0070.08319.36
5.4.440.0200.07019.43
5.4.430.0070.04319.46
5.4.420.0100.06019.37
5.4.410.0030.07319.20
5.4.400.0030.07319.01
5.4.390.0070.04718.95
5.4.380.0030.08018.88
5.4.370.0070.04319.13
5.4.360.0100.08319.00
5.4.350.0030.04019.13
5.4.340.0000.05018.95
5.4.320.0030.08019.13
5.4.310.0100.05718.95
5.4.300.0070.06718.98
5.4.290.0170.06718.96
5.4.280.0100.07719.12
5.4.270.0070.05719.04
5.4.260.0030.03719.15
5.4.250.0000.04319.11
5.4.240.0030.03719.26
5.4.230.0000.04019.00
5.4.220.0000.04019.04
5.4.210.0070.03719.04
5.4.200.0000.05719.04
5.4.190.0030.03719.04
5.4.180.0030.03719.11
5.4.170.0030.03719.04
5.4.160.0030.03719.00
5.4.150.0000.04018.97
5.4.140.0100.03016.35
5.4.130.0030.03716.29
5.4.120.0000.03716.40
5.4.110.0000.03716.45
5.4.100.0100.02716.39
5.4.90.0070.03316.45
5.4.80.0070.03016.40
5.4.70.0070.03316.29
5.4.60.0070.03016.29
5.4.50.0030.03316.34
5.4.40.0070.03016.47
5.4.30.0030.04016.40
5.4.20.0030.03316.46
5.4.10.0000.03716.34
5.4.00.0070.03715.70
5.3.290.0030.06314.91
5.3.280.0070.03314.69
5.3.270.0070.05714.67
5.3.260.0000.04014.74
5.3.250.0070.03314.71
5.3.240.0030.03714.74
5.3.230.0070.03314.67
5.3.220.0070.03314.81
5.3.210.0030.03714.55
5.3.200.0030.03714.64
5.3.190.0000.04014.61
5.3.180.0000.04014.63
5.3.170.0030.03314.63
5.3.160.0000.03714.59
5.3.150.0030.04014.63
5.3.140.0030.04014.66
5.3.130.0030.03714.53
5.3.120.0000.04014.63
5.3.110.0030.03714.58
5.3.100.0030.03314.02
5.3.90.0000.03714.07
5.3.80.0070.03014.09
5.3.70.0000.03714.09
5.3.60.0000.03713.93
5.3.50.0030.03714.00
5.3.40.0030.03313.98
5.3.30.0030.04013.79
5.3.20.0100.07013.58
5.3.10.0030.05313.89
5.3.00.0000.07713.68
5.2.170.0070.03011.16
5.2.160.0100.04311.19
5.2.150.0000.06011.20
5.2.140.0070.05011.10
5.2.130.0030.05311.13
5.2.120.0030.06311.18
5.2.110.0100.05011.04
5.2.100.0030.06311.10
5.2.90.0030.06311.16
5.2.80.0100.05311.19
5.2.70.0100.05011.18
5.2.60.0070.03310.99
5.2.50.0000.04711.16
5.2.40.0100.05711.01
5.2.30.0070.06010.85
5.2.20.0100.05710.89
5.2.10.0000.05310.75
5.2.00.0070.03010.75
5.1.60.0000.03010.04
5.1.50.0070.03310.02
5.1.40.0030.04710.09
5.1.30.0070.05710.36
5.1.20.0000.06010.45
5.1.10.0000.04010.14
5.1.00.0000.05710.02
5.0.50.0100.0438.57
5.0.40.0030.0378.57
5.0.30.0030.0638.57
5.0.20.0000.0378.57
5.0.10.0030.0308.57
5.0.00.0000.0678.57
4.4.90.0000.0378.57
4.4.80.0030.0138.57
4.4.70.0000.0378.57
4.4.60.0000.0308.57
4.4.50.0030.0338.57
4.4.40.0070.0508.57
4.4.30.0030.0278.57
4.4.20.0000.0278.57
4.4.10.0030.0238.57
4.4.00.0070.0338.57
4.3.110.0030.0378.57
4.3.100.0000.0378.57
4.3.90.0030.0308.57
4.3.80.0000.0538.57
4.3.70.0030.0338.57
4.3.60.0070.0278.57
4.3.50.0000.0378.57
4.3.40.0070.0508.57
4.3.30.0030.0278.57
4.3.20.0000.0338.57
4.3.10.0070.0308.57
4.3.00.0000.0238.57

preferences:
44.17 ms | 401 KiB | 5 Q