3v4l.org

run code in 300+ PHP versions simultaneously
<?php // simple example $bcast = ip2long("192.168.178.255"); $smask = ip2long("255.255.255.0"); $nmask = $bcast & $smask; echo long2ip($nmask); // Will give 192.168.178.0 ?> With this example you are able to check if a given host is in your own local net or not (on linux): <?php /** * Check if a client IP is in our Server subnet * * @param string $client_ip * @param string $server_ip * @return boolean */ function clientInSameSubnet($client_ip=false,$server_ip=false) { if (!$client_ip) $client_ip = $_SERVER['REMOTE_ADDR']; if (!$server_ip) $server_ip = $_SERVER['SERVER_ADDR']; // Extract broadcast and netmask from ifconfig if (!($p = popen("ifconfig","r"))) return false; $out = ""; while(!feof($p)) $out .= fread($p,1024); fclose($p); // This is because the php.net comment function does not // allow long lines. $match = "/^.*".$server_ip; $match .= ".*Bcast:(\d{1,3}\.\d{1,3}i\.\d{1,3}\.\d{1,3}).*"; $match .= "Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/im"; if (!preg_match($match,$out,$regs)) return false; $bcast = ip2long($regs[1]); $smask = ip2long($regs[2]); $ipadr = ip2long($client_ip); $nmask = $bcast & $smask; return (($ipadr & $smask) == ($nmask & $smask)); } ?>

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.00716.63
8.3.50.0080.00821.99
8.3.40.0040.01118.95
8.3.30.0110.00419.05
8.3.20.0040.00420.32
8.3.10.0030.00621.73
8.3.00.0080.00019.58
8.2.180.0190.00316.63
8.2.170.0140.00022.96
8.2.160.0070.00720.39
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00021.06
8.2.110.0060.00322.20
8.2.100.0170.00017.84
8.2.90.0030.00519.21
8.2.80.0000.00917.97
8.2.70.0030.00717.50
8.2.60.0050.00318.16
8.2.50.0040.00418.07
8.2.40.0000.00818.16
8.2.30.0060.00318.33
8.2.20.0000.00817.68
8.2.10.0040.00418.09
8.2.00.0050.00317.69
8.1.280.0130.00625.92
8.1.270.0030.00624.09
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0000.00923.91
8.1.230.0070.00419.28
8.1.220.0060.00317.79
8.1.210.0050.00318.77
8.1.200.0060.00617.22
8.1.190.0040.00417.22
8.1.180.0000.00918.10
8.1.170.0000.00818.64
8.1.160.0080.00021.97
8.1.150.0040.00418.82
8.1.140.0040.00417.36
8.1.130.0030.00317.83
8.1.120.0070.00017.54
8.1.110.0030.00517.55
8.1.100.0000.00717.52
8.1.90.0070.00017.58
8.1.80.0000.00817.50
8.1.70.0000.00717.48
8.1.60.0000.00717.59
8.1.50.0030.00517.40
8.1.40.0030.00517.45
8.1.30.0030.00617.72
8.1.20.0000.00817.68
8.1.10.0020.00517.62
8.1.00.0030.00617.51
8.0.300.0040.00418.77
8.0.290.0030.00616.63
8.0.280.0030.00518.54
8.0.270.0030.00317.30
8.0.260.0030.00317.34
8.0.250.0030.00317.09
8.0.240.0040.00417.07
8.0.230.0040.00417.02
8.0.220.0050.00516.79
8.0.210.0070.00016.98
8.0.200.0000.00717.00
8.0.190.0040.00417.05
8.0.180.0050.00316.98
8.0.170.0040.00416.96
8.0.160.0000.00716.91
8.0.150.0040.00416.88
8.0.140.0070.00416.88
8.0.130.0060.00013.50
8.0.120.0040.00416.91
8.0.110.0080.00016.93
8.0.100.0040.00416.71
8.0.90.0000.00717.04
8.0.80.0060.00916.90
8.0.70.0030.00616.80
8.0.60.0000.00816.83
8.0.50.0030.00516.83
8.0.30.0130.00617.21
8.0.20.0140.00417.40
8.0.10.0040.00417.02
8.0.00.0070.01116.70
7.4.330.0050.00015.20
7.4.320.0000.00616.53
7.4.300.0060.00016.59
7.4.290.0050.00216.71
7.4.280.0000.00716.52
7.4.270.0070.00016.55
7.4.260.0070.00016.58
7.4.250.0040.00416.52
7.4.240.0040.00316.58
7.4.230.0080.00016.65
7.4.220.0090.00616.79
7.4.210.0030.01216.50
7.4.200.0000.00716.78
7.4.160.0100.01316.66
7.4.150.0070.01017.40
7.4.140.0150.00417.86
7.4.130.0080.00916.53
7.4.120.0130.00316.53
7.4.110.0060.01316.38
7.4.100.0160.00716.73
7.4.90.0030.01516.53
7.4.80.0080.01219.39
7.4.70.0030.01316.78
7.4.60.0070.01316.43
7.4.50.0000.00516.66
7.4.40.0060.01016.55
7.4.30.0000.01616.54
7.4.00.0130.00514.87
7.3.330.0000.00513.29
7.3.320.0020.00213.33
7.3.310.0030.00316.38
7.3.300.0030.00316.22
7.3.290.0060.00916.32
7.3.280.0030.01416.31
7.3.270.0140.00317.40
7.3.260.0170.00416.64
7.3.250.0090.01016.48
7.3.240.0090.00916.54
7.3.230.0090.00916.54
7.3.210.0160.00716.30
7.3.200.0030.01319.39
7.3.190.0080.01016.51
7.3.180.0030.01316.57
7.3.170.0100.00616.40
7.3.160.0070.01016.56
7.3.120.0110.00414.79
7.3.110.0100.01015.12
7.3.100.0040.01114.89
7.3.90.0030.01214.60
7.3.80.0070.00715.18
7.3.70.0090.00314.84
7.3.60.0030.00714.97
7.3.50.0070.00414.79
7.3.40.0030.01014.98
7.3.30.0030.01214.86
7.3.20.0070.00716.73
7.3.10.0080.00616.24
7.3.00.0050.00916.41
7.2.330.0090.00916.69
7.2.320.0100.00716.82
7.2.310.0120.00416.75
7.2.300.0070.01016.56
7.2.290.0070.01016.71
7.2.250.0140.00714.84
7.2.240.0100.01015.26
7.2.230.0030.01014.91
7.2.220.0060.00615.02
7.2.210.0080.00314.86
7.2.200.0000.01715.12
7.2.190.0000.01014.75
7.2.180.0070.00715.16
7.2.170.0030.01215.18
7.2.130.0090.00916.58
7.2.120.0110.00716.70
7.2.110.0090.00916.44
7.2.100.0110.01416.74
7.2.90.0130.00716.50
7.2.80.0070.00716.86
7.2.70.0170.00016.71
7.2.60.0090.00916.71
7.2.50.0150.00616.84
7.2.40.0130.00716.53
7.2.30.0070.01316.54
7.2.20.0110.00416.71
7.2.10.0090.00916.67
7.2.00.0050.01018.20
7.1.330.0030.01015.52
7.1.320.0100.00715.85
7.1.310.0080.00415.55
7.1.300.0030.01015.52
7.1.290.0000.01115.84
7.1.280.0060.00615.71
7.1.270.0100.00715.86
7.1.260.0130.00015.63
7.1.250.0120.00315.58
7.1.200.0080.00415.67
7.1.100.0000.00918.02
7.1.70.0030.00817.17
7.1.60.0140.01019.25
7.1.50.0070.01816.95
7.1.00.0000.08022.38
7.0.200.0150.00616.73
7.0.140.0070.07022.15
7.0.60.0100.04019.87
7.0.50.0100.07718.02
7.0.40.0000.04720.08
7.0.30.0500.07320.23
7.0.20.0200.05320.32
7.0.10.0070.06720.39
7.0.00.0030.04020.15
5.6.280.0030.07321.06
5.6.210.0130.05720.57
5.6.200.0130.08018.18
5.6.190.0000.05720.52
5.6.180.3530.04320.61
5.6.170.0170.04720.62
5.6.160.0030.04020.56
5.6.150.0230.05318.20
5.6.140.0100.06318.34
5.6.130.0100.08318.23
5.6.120.0270.04021.03
5.6.110.0070.08721.03
5.6.100.0000.07321.21
5.6.90.0070.06020.98
5.6.80.0000.04020.41
5.5.350.4170.04320.45
5.5.340.0070.08018.05
5.5.330.0030.04720.28
5.5.320.0330.07020.33
5.5.310.0230.05320.57
5.5.300.0070.08718.05
5.5.290.0070.04718.13
5.5.280.0100.05020.84
5.5.270.0070.05020.71
5.5.260.0130.07720.80
5.5.250.0100.06320.72
5.5.240.0200.07320.30
5.4.450.1200.03319.71
5.4.440.1500.05019.47
5.4.430.1100.04319.53
5.4.420.1270.04019.46
5.4.410.0000.03319.44
5.4.400.1070.04719.14
5.4.390.1330.03319.15
5.4.380.0330.05718.80
5.4.370.0370.05718.90
5.4.360.0430.05318.90
5.4.350.0330.05718.58
5.4.340.0400.05318.84
5.4.320.0090.03812.51
5.4.310.0080.04312.51
5.4.300.0070.03712.51
5.4.290.0050.03912.51
5.4.280.0030.03812.41
5.4.270.0080.03512.41
5.4.260.0050.03912.41
5.4.250.0060.03712.41
5.4.240.0060.03612.41
5.4.230.0080.04012.39
5.4.220.0030.04412.40
5.4.210.0050.03812.40
5.4.200.0060.03812.39
5.4.190.0070.03712.39
5.4.180.0070.03512.40
5.4.170.0060.04412.40
5.4.160.0070.03512.40
5.4.150.0040.03812.39
5.4.140.0070.03612.08
5.4.130.0070.03512.07
5.4.120.0070.03412.03
5.4.110.0040.03712.02
5.4.100.0050.03612.02
5.4.90.0070.03812.02
5.4.80.0050.03912.02
5.4.70.0070.03512.02
5.4.60.0060.03512.02
5.4.50.0080.03312.02
5.4.40.0060.03612.00
5.4.30.0070.03912.00
5.4.20.0050.03812.00
5.4.10.0070.03312.00
5.4.00.0060.03611.49
5.3.290.0120.04312.80
5.3.280.0030.04112.71
5.3.270.0050.04212.72
5.3.260.0060.04412.71
5.3.250.0070.04112.72
5.3.240.0060.03912.72
5.3.230.0040.04012.71
5.3.220.0060.03712.68
5.3.210.0060.03912.68
5.3.200.0080.03512.68
5.3.190.0040.04012.68
5.3.180.0060.04212.68
5.3.170.0060.03912.67
5.3.160.0080.03512.67
5.3.150.0060.04812.68
5.3.140.0050.05412.66
5.3.130.0070.04612.66
5.3.120.0070.04312.66
5.3.110.0050.04412.66
5.3.100.0070.03712.12
5.3.90.0050.03612.10
5.3.80.0060.03712.09
5.3.70.0030.04012.10
5.3.60.0060.04112.08
5.3.50.0080.03512.03
5.3.40.0040.03912.03
5.3.30.0070.03411.98
5.3.20.0040.03611.77
5.3.10.0040.03611.73
5.3.00.0060.03611.73
5.2.170.0050.0309.24
5.2.160.0040.0309.24
5.2.150.0060.0299.24
5.2.140.0060.0289.23
5.2.130.0050.0289.20
5.2.120.0020.0319.20
5.2.110.0050.0299.20
5.2.100.0030.0309.20
5.2.90.0080.0259.19
5.2.80.0040.0319.19
5.2.70.0030.0319.18
5.2.60.0070.0289.15
5.2.50.0050.0309.12
5.2.40.0060.0289.10
5.2.30.0010.0349.06
5.2.20.0070.0279.06
5.2.10.0030.0318.96
5.2.00.0030.0308.83
5.1.60.0040.0258.12
5.1.50.0040.0268.11
5.1.40.0040.0268.09
5.1.30.0030.0278.44
5.1.20.0040.0278.46
5.1.10.0040.0278.19
5.1.00.0030.0278.19
5.0.50.0050.0206.67
5.0.40.0030.0206.54
5.0.30.0060.0296.35
5.0.20.0030.0196.30
5.0.10.0020.0216.29
5.0.00.0040.0296.28
4.4.90.0010.0174.78
4.4.80.0050.0124.75
4.4.70.0040.0144.75
4.4.60.0030.0164.75
4.4.50.0030.0154.77
4.4.40.0060.0224.71
4.4.30.0040.0144.76
4.4.20.0030.0154.84
4.4.10.0040.0144.85
4.4.00.0010.0284.76
4.3.110.0020.0164.67
4.3.100.0040.0144.67
4.3.90.0010.0164.64
4.3.80.0030.0244.59
4.3.70.0030.0144.63
4.3.60.0010.0164.63
4.3.50.0020.0164.63
4.3.40.0010.0264.54
4.3.30.0020.0163.33
4.3.20.0010.0173.31
4.3.10.0040.0143.27
4.3.00.0170.01315.25

preferences:
41.17 ms | 401 KiB | 5 Q