3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ip = '127.0.0.1'; function test($ip) { if (false !== strpos($ip, '/')) { list($address, $netmask) = explode('/', $ip, 2); if ($netmask < 1 || $netmask > 32) { return false; } } else { $address = $ip; $netmask = 32; } $netmask = str_pad(str_pad('', $netmask, '1'), 32, '0'); $in_addr = ''; foreach(array_map('bindec', str_split($netmask, 8)) as $char) { $in_addr .= pack('C*', $char); } $netmask = inet_pton(inet_ntop($in_addr)); $network = (inet_pton($address) & $netmask); return [inet_ntop($network), inet_ntop($network | ~$netmask)]; } var_dump(test('127.0.0.1')); var_dump(test('10.0.0.3/29')); var_dump(test('192.168.1.16/8'));

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.0110.00717.00
8.3.50.0110.01022.04
8.3.40.0070.00719.13
8.3.30.0110.00419.09
8.3.20.0050.00320.59
8.3.10.0080.00023.95
8.3.00.0080.00019.63
8.2.180.0180.00418.43
8.2.170.0070.00722.96
8.2.160.0070.01020.39
8.2.150.0050.00524.18
8.2.140.0080.00024.66
8.2.130.0090.00019.43
8.2.120.0080.00026.35
8.2.110.0000.00920.71
8.2.100.0120.00018.05
8.2.90.0040.00419.34
8.2.80.0040.00417.97
8.2.70.0000.00817.63
8.2.60.0030.00618.16
8.2.50.0030.00518.07
8.2.40.0030.00519.52
8.2.30.0040.00420.66
8.2.20.0030.00617.87
8.2.10.0080.00018.26
8.2.00.0000.00718.20
8.1.280.0100.00725.92
8.1.270.0060.00323.95
8.1.260.0080.00028.09
8.1.250.0050.00328.09
8.1.240.0060.00323.97
8.1.230.0060.00617.78
8.1.220.0070.00417.74
8.1.210.0000.00818.77
8.1.200.0030.00717.48
8.1.190.0050.00317.35
8.1.180.0040.00418.10
8.1.170.0090.00020.61
8.1.160.0000.00822.14
8.1.150.0040.00418.93
8.1.140.0040.00419.65
8.1.130.0040.00417.68
8.1.120.0040.00417.57
8.1.110.0070.00017.54
8.1.100.0000.00717.53
8.1.90.0040.00417.51
8.1.80.0040.00417.53
8.1.70.0030.00517.54
8.1.60.0050.00517.70
8.1.50.0080.00017.48
8.1.40.0050.00517.63
8.1.30.0030.00617.76
8.1.20.0000.00817.77
8.1.10.0050.00317.64
8.1.00.0040.00417.66
8.0.300.0070.00018.77
8.0.290.0040.00416.75
8.0.280.0080.00018.53
8.0.270.0040.00417.30
8.0.260.0030.00317.34
8.0.250.0000.00717.04
8.0.240.0070.00017.01
8.0.230.0000.00716.98
8.0.220.0030.00316.88
8.0.210.0000.00817.02
8.0.200.0040.00417.09
8.0.190.0040.00416.98
8.0.180.0000.00817.05
8.0.170.0040.00416.95
8.0.160.0030.00416.98
8.0.150.0030.00316.90
8.0.140.0040.00416.86
8.0.130.0030.00313.52
8.0.120.0050.00317.01
8.0.110.0040.00416.96
8.0.100.0040.00417.01
8.0.90.0040.00416.99
8.0.80.0070.01016.86
8.0.70.0000.00716.96
8.0.60.0040.00416.98
8.0.50.0040.00417.06
8.0.30.0110.00817.24
8.0.20.0090.01117.40
8.0.10.0000.00716.95
8.0.00.0100.00717.01
7.4.330.0000.00617.03
7.4.320.0030.00316.66
7.4.300.0060.00016.61
7.4.290.0000.00716.54
7.4.280.0040.00416.66
7.4.270.0040.00416.73
7.4.260.0030.00316.59
7.4.250.0040.00416.52
7.4.240.0040.00416.65
7.4.230.0030.00316.76
7.4.220.0080.01116.71
7.4.210.0090.00616.64
7.4.200.0040.00416.77
7.4.160.0030.01316.53
7.4.150.0040.01517.40
7.4.140.0100.00817.86
7.4.130.0070.01016.52
7.4.120.0080.01316.63
7.4.110.0160.00916.75
7.4.100.0160.00716.51
7.4.90.0100.01416.56
7.4.80.0120.00619.39
7.4.70.0060.01016.50
7.4.60.0100.00716.54
7.4.50.0000.01516.54
7.4.40.0030.01316.43
7.4.30.0090.00916.77
7.4.00.0000.01315.27
7.3.330.0060.00013.55
7.3.320.0000.00513.30
7.3.310.0020.00516.46
7.3.300.0030.00316.45
7.3.290.0010.01416.46
7.3.280.0100.01016.42
7.3.270.0100.00917.40
7.3.260.0150.00316.55
7.3.250.0090.00816.56
7.3.240.0080.00916.49
7.3.230.0120.00616.46
7.3.210.0140.00316.60
7.3.200.0060.01016.55
7.3.190.0070.01016.42
7.3.180.0110.01116.53
7.3.170.0100.00716.36
7.3.160.0130.01016.61
7.3.10.0120.00716.24
7.3.00.0100.00816.60
7.2.330.0040.01316.84
7.2.320.0080.01116.54
7.2.310.0180.00616.58
7.2.300.0090.00916.72
7.2.290.0100.01316.87
7.2.130.0070.00916.76
7.2.120.0100.00616.81
7.2.110.0170.00516.69
7.2.100.0100.00916.73
7.2.90.0070.01216.83
7.2.80.0120.00916.81
7.2.70.0100.00816.86
7.2.60.0100.00916.81
7.2.50.0110.00516.76
7.2.40.0070.00816.74
7.2.30.0110.00816.89
7.2.20.0100.00716.70
7.2.10.0020.01516.96
7.2.00.0140.00717.06
7.1.250.0090.00815.79
7.1.200.0040.01315.67
7.1.100.0030.01418.38
7.1.70.0000.00717.13
7.1.60.0170.00719.48
7.1.50.0000.02117.00
7.1.00.0070.07022.34
7.0.200.0410.00314.74
7.0.60.0030.09320.05
7.0.50.0100.03318.03
7.0.40.0100.03720.29
7.0.30.0470.06320.30
7.0.20.0200.05720.29
7.0.10.0070.08720.30
7.0.00.0070.08320.30
5.6.280.0000.05721.16
5.6.210.0070.04720.54
5.6.200.0170.06718.21
5.6.190.0130.07720.69
5.6.180.0330.07720.69
5.6.170.0330.07020.56
5.6.160.0200.07020.52
5.6.150.0030.08318.24
5.6.140.0100.06318.18
5.6.130.0100.06318.20
5.6.120.0000.05721.10
5.6.110.0130.08321.18
5.6.100.0000.04721.06
5.6.90.0130.07021.15
5.6.80.0070.06720.43
5.5.350.4200.04020.48
5.5.340.0000.04318.14
5.5.330.0170.04720.25
5.5.320.0030.04020.26
5.5.310.0130.06320.32
5.5.300.0100.03718.01
5.5.290.0030.05018.14
5.5.280.0130.05020.86
5.5.270.0000.08720.99
5.5.260.0030.04320.84
5.5.250.0130.08020.84
5.5.240.0230.07720.07

preferences:
35.34 ms | 401 KiB | 5 Q