3v4l.org

run code in 300+ PHP versions simultaneously
<?php $answer = 1; // The Setup settype($answer, 'integer'); $s = (string) $a = &$answer; $ns = (string) $n = (isset($s[1])) ? ($a >> 1)+$s[1] : ($a >> 1)+$s[0]; $f = ((int) $ns[0] ^ (int) $s[1]); // The Riddle function riddle($a, $n, $s, $f, $ns) { if ( ($a != 0 && luhn($a)) && (!$f) && (($n | $a) == 63) && (!isset($s[2])) ) { return TRUE; } return FALSE; } // The Result if (riddle($a, $n, $s, $f, $ns)) { echo "You got the correct answer! ($a)"; } else { echo "Sorry, wrong answer. ($a)"; } function luhn($number) { settype($number, 'string'); $sumTable = array( array(0,1,2,3,4,5,6,7,8,9), array(0,2,4,6,8,1,3,5,7,9)); $sum = 0; $flip = 0; for ($i = strlen($number) - 1; $i >= 0; $i--) { $sum += $sumTable[$flip++ & 0x1][$number[$i]]; } return $sum % 10 === 0; }

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.0060.00916.75
8.3.50.0110.00722.05
8.3.40.0120.00318.98
8.3.30.0040.01119.14
8.3.20.0080.00020.27
8.3.10.0120.00621.91
8.3.00.0080.00019.15
8.2.180.0060.00918.25
8.2.170.0080.00822.96
8.2.160.0100.00320.43
8.2.150.0030.00524.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0000.00820.80
8.2.110.0120.00819.33
8.2.100.0080.00317.91
8.2.90.0000.00819.21
8.2.80.0050.00317.97
8.2.70.0030.00617.63
8.2.60.0060.00317.93
8.2.50.0060.00318.07
8.2.40.0000.00820.07
8.2.30.0000.00818.33
8.2.20.0080.00017.74
8.2.10.0040.00418.19
8.2.00.0000.00717.90
8.1.280.0110.00425.92
8.1.270.0060.00323.96
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0050.00322.19
8.1.230.0060.00620.70
8.1.220.0030.00617.75
8.1.210.0080.00018.77
8.1.200.0070.00317.35
8.1.190.0040.00417.23
8.1.180.0080.00418.10
8.1.170.0030.00618.46
8.1.160.0040.00422.06
8.1.150.0100.00018.69
8.1.140.0080.00017.54
8.1.130.0000.00717.91
8.1.120.0000.00717.57
8.1.110.0060.00317.46
8.1.100.0040.00417.50
8.1.90.0050.00317.40
8.1.80.0050.00317.40
8.1.70.0000.00717.44
8.1.60.0000.00817.46
8.1.50.0030.00517.62
8.1.40.0000.00817.57
8.1.30.0050.00317.62
8.1.20.0000.00817.66
8.1.10.0030.00617.52
8.1.00.0030.00617.54
8.0.300.0060.00318.77
8.0.290.0080.00016.75
8.0.280.0030.00318.48
8.0.270.0040.00417.29
8.0.260.0000.00617.29
8.0.250.0000.00716.96
8.0.240.0040.00416.93
8.0.230.0050.00217.07
8.0.220.0030.00316.96
8.0.210.0000.00716.91
8.0.200.0060.00017.12
8.0.190.0070.00017.07
8.0.180.0040.00416.91
8.0.170.0080.00017.06
8.0.160.0050.00316.93
8.0.150.0000.00816.97
8.0.140.0000.00716.99
8.0.130.0030.00313.42
8.0.120.0080.00016.96
8.0.110.0080.00016.86
8.0.100.0030.00516.87
8.0.90.0030.00516.88
8.0.80.0030.01216.88
8.0.70.0000.00716.90
8.0.60.0000.00716.81
8.0.50.0030.00516.95
8.0.30.0100.01017.26
8.0.20.0090.01217.40
8.0.10.0040.00416.92
8.0.00.0080.01116.80
7.4.330.0000.00515.00
7.4.320.0000.00616.41
7.4.300.0020.00516.53
7.4.290.0040.00416.69
7.4.280.0030.00316.54
7.4.270.0000.00716.65
7.4.260.0070.00016.52
7.4.250.0040.00416.52
7.4.240.0040.00416.60
7.4.230.0030.00616.66
7.4.220.0070.01416.60
7.4.210.0090.00616.63
7.4.200.0000.00716.71
7.4.190.0000.00716.80
7.4.160.0060.01016.61
7.4.150.0170.00317.40
7.4.140.0110.00817.86
7.4.130.0140.00516.63
7.4.120.0090.01216.62
7.4.110.0110.00616.46
7.4.100.0100.00716.63
7.4.90.0110.00616.52
7.4.80.0090.00819.39
7.4.70.0080.00816.57
7.4.60.0040.01416.46
7.4.50.0040.00416.45
7.4.40.0080.01216.73
7.4.30.0080.00816.71
7.4.00.0090.00515.15
7.3.330.0000.00513.25
7.3.320.0000.00513.23
7.3.310.0070.00016.44
7.3.300.0030.00316.39
7.3.290.0100.00316.46
7.3.280.0100.00916.45
7.3.270.0180.00017.40
7.3.260.0080.00816.38
7.3.250.0130.01016.44
7.3.240.0100.00716.37
7.3.230.0060.01016.42
7.3.210.0180.00316.46
7.3.200.0060.01019.39
7.3.190.0120.01216.63
7.3.180.0060.00916.44
7.3.170.0030.01316.44
7.3.160.0130.00316.65
7.3.120.0090.00714.91
7.3.110.0110.00714.89
7.3.100.0060.00914.92
7.3.90.0070.00714.95
7.3.80.0070.00714.92
7.3.70.0090.00615.04
7.3.60.0000.00914.95
7.3.50.0060.00614.76
7.3.40.0030.01015.04
7.3.30.0130.00314.86
7.3.20.0080.00316.82
7.3.10.0100.00316.79
7.3.00.0030.01216.61
7.2.330.0090.00916.70
7.2.320.0090.00916.74
7.2.310.0100.00716.52
7.2.300.0030.01716.52
7.2.290.0070.01016.51
7.2.250.0170.00315.40
7.2.240.0070.01414.76
7.2.230.0000.01015.27
7.2.220.0110.00414.76
7.2.210.0080.00515.40
7.2.200.0030.00914.79
7.2.190.0060.00615.24
7.2.180.0000.00915.14
7.2.170.0030.01215.30
7.2.60.0070.01016.80
7.2.00.0040.01119.52
7.1.330.0030.01315.88
7.1.320.0060.00615.82
7.1.310.0030.01015.82
7.1.300.0040.01115.67
7.1.290.0000.01115.82
7.1.280.0040.01115.69
7.1.270.0060.00315.87
7.1.260.0000.01115.80
7.1.200.0030.00915.95
7.1.100.0340.00012.03
7.1.70.0040.00717.17
7.1.60.0120.01219.46
7.1.50.0120.00917.00
7.1.00.0000.08022.43
7.0.200.0040.00416.63
7.0.140.0030.07322.12
7.0.60.0000.08719.95
7.0.50.0000.04717.88
7.0.40.0070.05320.11
7.0.30.0230.03720.12
7.0.20.0330.04720.17
7.0.10.0130.07720.26
7.0.00.0030.05720.16
5.6.210.0100.07720.55
5.6.200.0070.06318.25
5.6.190.0070.06020.52
5.6.180.0330.06720.52
5.6.170.0200.07720.56
5.6.160.0100.08020.71
5.6.150.0030.04018.18
5.6.140.0130.07718.19
5.6.130.0030.08318.23
5.6.120.0100.08020.97
5.6.110.0100.07721.02
5.6.100.0070.04021.02
5.6.90.0100.08320.98
5.6.80.0100.08020.37
5.5.350.3770.04320.39
5.5.340.0030.05718.05
5.5.330.0070.04020.19
5.5.320.0270.04320.27
5.5.310.0300.07720.30
5.5.300.0000.05017.92
5.5.290.0100.08317.97
5.5.280.0070.05720.78
5.5.270.0070.04020.97
5.5.260.0100.07020.88
5.5.250.0100.06320.70
5.5.240.0030.08020.07
5.4.450.0200.04319.53
5.4.440.0300.04719.46
5.4.430.0430.03751.48
5.4.420.0430.02748.08
5.4.410.0270.04743.21
5.4.400.0200.04041.23
5.4.390.0270.03739.08
5.4.380.0330.06718.70
5.4.370.0300.05318.83
5.4.360.0500.03718.74
5.4.350.0400.05718.78
5.4.340.0370.06718.74
5.4.320.0050.03712.51
5.4.310.0070.03612.51
5.4.300.0050.04412.51
5.4.290.0100.05812.51
5.4.280.0080.06112.41
5.4.270.0150.07012.40
5.4.260.0100.05912.40
5.4.250.0100.05512.40
5.4.240.0050.05412.40
5.4.230.0070.05412.39
5.4.220.0110.04812.39
5.4.210.0050.05312.40
5.4.200.0050.05512.39
5.4.190.0070.05312.39
5.4.180.0100.06412.39
5.4.170.0140.06512.40
5.4.160.0090.05512.39
5.4.150.0070.05012.39
5.4.140.0090.04812.07
5.4.130.0130.04212.06
5.4.120.0060.05012.02
5.4.110.0040.04612.02
5.4.100.0050.04612.02
5.4.90.0080.03912.02
5.4.80.0050.05012.02
5.4.70.0090.04912.01
5.4.60.0070.05412.02
5.4.50.0090.04512.02
5.4.40.0070.05612.00
5.4.30.0070.05412.00
5.4.20.0130.04311.99
5.4.10.0070.04412.00
5.4.00.0080.03811.49
5.3.290.0050.04712.80
5.3.280.0090.04012.71
5.3.270.0090.04112.72
5.3.260.0100.05412.71
5.3.250.0110.05512.72
5.3.240.0060.05412.72
5.3.230.0110.04812.71
5.3.220.0060.05612.68
5.3.210.0120.05412.68
5.3.200.0100.05312.68
5.3.190.0110.05112.68
5.3.180.0070.05312.67
5.3.170.0090.05212.67
5.3.160.0090.05112.68
5.3.150.0090.04812.67
5.3.140.0130.04312.66
5.3.130.0070.04812.65
5.3.120.0090.04612.65
5.3.110.0090.04512.66
5.3.100.0090.04712.13
5.3.90.0080.04712.11
5.3.80.0090.03912.10
5.3.70.0110.04312.10
5.3.60.0120.04612.08
5.3.50.0080.04512.04
5.3.40.0060.04512.04
5.3.30.0100.04011.99
5.3.20.0050.04411.77
5.3.10.0090.05011.73
5.3.00.0090.06111.72
5.2.170.0080.0369.22
5.2.160.0130.0739.23
5.2.150.0120.0519.22
5.2.140.0040.0379.23
5.2.130.0080.0499.18
5.2.120.0080.0319.18
5.2.110.0080.0349.19
5.2.100.0040.0359.18
5.2.90.0070.0439.18
5.2.80.0080.0339.18
5.2.70.0070.0399.18
5.2.60.0070.0419.14
5.2.50.0090.0309.11
5.2.40.0100.0339.08
5.2.30.0120.0479.06
5.2.20.0100.0419.05
5.2.10.0070.0418.95
5.2.00.0080.0428.82
5.1.60.0040.0398.11
5.1.50.0070.0338.10
5.1.40.0060.0358.08
5.1.30.0080.0438.43
5.1.20.0050.0388.45
5.1.10.0050.0338.18
5.1.00.0060.0348.18
5.0.50.0040.0316.67
5.0.40.0070.0276.53
5.0.30.0110.0456.34
5.0.20.0080.0226.31
5.0.10.0060.0256.29
5.0.00.0040.0396.28
4.4.90.0050.0194.78
4.4.80.0030.0234.76
4.4.70.0050.0204.75
4.4.60.0000.0244.75
4.4.50.0020.0234.77
4.4.40.0020.0334.71
4.4.30.0010.0244.76
4.4.20.0030.0224.85
4.4.10.0080.0164.85
4.4.00.0030.0344.76
4.3.110.0080.0204.67
4.3.100.0050.0214.66
4.3.90.0070.0194.63
4.3.80.0080.0314.59
4.3.70.0040.0224.63
4.3.60.0060.0214.63
4.3.50.0050.0224.63
4.3.40.0040.0304.54
4.3.30.0030.0213.33
4.3.20.0020.0233.31
4.3.10.0020.0213.25
4.3.00.0070.01337.99

preferences:
49.63 ms | 401 KiB | 5 Q