3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @file A fizzbuzz reference implementation. * @author Brad Czerniak (ao5357@gmail.com) */ /** * Outputs fizzes and buzzes over a loop. * * @param int $iterations * The number of times to iterate over the loop * @param int $offset * The number to start at * @param string $fizz * The string to output for the first modulo condition, typically 'fizz'. * @param string $buzz * The string to output for the second modulo condition, typically 'buzz'. * @param string $fizzbuzz * The string to output for the third (usually combined) modulo condition, typically 'fizzbuzz'. * @param int $fizz_int * The first modulus * @param int $buzz_int * The second modulus * @param int $fizzbuzz_int * The third (usually combined) modulus * * @return An array of the loop's output */ function fizzbuzz($iterations = 100, $offset = 1, $fizz = 'fizz', $buzz = 'buzz', $fizzbuzz = 'fizzbuzz', $fizz_int = 3, $buzz_int = 5, $fizzbuzz_int = 15) { $i = $offset; $ret = array(); while($i < ($offset + $iterations)){ if($i % $fizzbuzz_int == 0){ $ret[$i] = $fizzbuzz;} elseif($i % $buzz_int == 0){ $ret[$i] = $buzz;} elseif($i % $fizz_int == 0){ $ret[$i] = $fizz;} else{ $ret[$i] = $i;} $i++; } return $ret; } print_r(fizzbuzz());

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.0150.00618.18
8.3.50.0100.00921.27
8.3.40.0040.01118.67
8.3.30.0030.01020.38
8.3.20.0000.00820.34
8.3.10.0060.00322.09
8.3.00.0030.00522.52
8.2.180.0030.01316.50
8.2.170.0040.01122.96
8.2.160.0100.00322.25
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0080.00020.64
8.2.110.0080.00322.25
8.2.100.0110.00017.78
8.2.90.0050.00317.63
8.2.80.0080.00018.05
8.2.70.0050.00318.03
8.2.60.0080.00017.93
8.2.50.0050.00318.10
8.2.40.0040.00420.52
8.2.30.0000.00819.58
8.2.20.0020.00517.79
8.2.10.0040.00417.68
8.2.00.0000.00717.74
8.1.280.0140.00425.92
8.1.270.0040.00423.99
8.1.260.0030.00626.35
8.1.250.0050.00328.09
8.1.240.0060.00324.02
8.1.230.0090.00319.04
8.1.220.0000.00817.78
8.1.210.0060.00318.77
8.1.200.0040.00417.35
8.1.190.0040.00417.25
8.1.180.0000.00818.10
8.1.170.0040.00418.52
8.1.160.0050.00218.91
8.1.150.0000.00818.71
8.1.140.0040.00417.54
8.1.130.0000.00717.38
8.1.120.0000.00817.46
8.1.110.0030.00717.45
8.1.100.0070.00017.45
8.1.90.0030.00417.50
8.1.80.0050.00217.37
8.1.70.0000.00717.45
8.1.60.0000.00917.64
8.1.50.0050.00217.57
8.1.40.0080.00017.53
8.1.30.0040.00417.64
8.1.20.0000.00917.61
8.1.10.0080.00017.57
8.1.00.0090.00017.53
8.0.300.0000.00719.73
8.0.290.0060.00316.75
8.0.280.0000.00718.51
8.0.270.0040.00417.21
8.0.260.0000.00716.85
8.0.250.0000.00717.02
8.0.240.0030.00516.91
8.0.230.0000.00716.93
8.0.220.0030.00316.92
8.0.210.0050.00316.90
8.0.200.0000.00716.99
8.0.190.0000.00716.88
8.0.180.0040.00416.83
8.0.170.0030.00516.83
8.0.160.0030.00316.88
8.0.150.0040.00416.81
8.0.140.0040.00416.86
8.0.130.0000.00613.35
8.0.120.0040.00416.73
8.0.110.0000.00716.81
8.0.100.0030.00516.94
8.0.90.0000.00716.79
8.0.80.0080.01216.90
8.0.70.0000.00716.79
8.0.60.0040.00416.94
8.0.50.0030.00616.79
8.0.30.0110.01116.95
8.0.20.0130.00517.40
8.0.10.0000.00717.10
8.0.00.0090.01416.69
7.4.330.0050.00015.02
7.4.320.0060.00016.53
7.4.300.0030.00316.43
7.4.290.0000.00716.42
7.4.280.0070.00016.62
7.4.270.0000.00916.54
7.4.260.0050.00013.40
7.4.250.0000.00816.59
7.4.240.0040.00416.59
7.4.230.0030.00316.45
7.4.220.0100.01316.62
7.4.210.0070.01016.63
7.4.200.0040.00416.34
7.4.190.0000.00716.43
7.4.160.0090.00616.52
7.4.150.0060.01217.40
7.4.140.0090.00917.86
7.4.130.0090.00816.51
7.4.120.0080.01116.52
7.4.110.0130.01016.68
7.4.100.0170.00016.45
7.4.90.0060.01116.42
7.4.80.0070.01419.39
7.4.70.0000.01616.57
7.4.60.0040.01616.71
7.4.50.0080.00016.50
7.4.40.0070.01022.77
7.4.30.0090.00616.34
7.4.00.0040.01215.04
7.3.330.0030.00313.27
7.3.320.0030.00313.37
7.3.310.0000.00716.42
7.3.300.0070.00016.45
7.3.290.0060.01316.40
7.3.280.0100.00816.38
7.3.270.0200.00017.40
7.3.260.0170.00416.48
7.3.250.0120.00416.34
7.3.240.0140.00416.46
7.3.230.0100.00716.39
7.3.210.0100.01016.56
7.3.200.0080.01119.39
7.3.190.0080.00816.39
7.3.180.0100.01016.59
7.3.170.0120.00916.47
7.3.160.0110.00716.63
7.3.120.0000.01014.70
7.2.330.0100.01016.70
7.2.320.0080.00916.71
7.2.310.0110.01016.68
7.2.300.0160.00616.65
7.2.290.0130.00316.66
7.2.60.0160.00616.90
7.2.50.0070.00716.95
7.2.00.0030.01219.22
7.1.200.0030.00915.52
7.1.100.0000.01117.82
7.1.70.0030.00717.18
7.1.60.0070.00717.37
7.1.50.0070.01417.04
7.1.00.0000.07722.57
7.0.200.0120.00616.95
7.0.140.0100.06322.18
7.0.70.0030.07721.70
7.0.60.0000.05321.73
7.0.50.0030.08022.09
7.0.40.0000.05720.12
7.0.30.0000.08720.07
7.0.20.0030.08720.13
7.0.10.0070.07720.14
7.0.00.0070.08720.10
5.6.280.0070.07321.11
5.6.220.0030.08320.58
5.6.210.0070.06320.67
5.6.200.0000.09021.01
5.6.190.0000.09321.06
5.6.180.0100.07021.02
5.6.170.0100.07320.96
5.6.160.0170.07720.94
5.6.150.0000.08021.01
5.6.140.0130.04021.08
5.6.130.0070.08321.02
5.6.120.0070.08721.17
5.6.110.0030.09021.17
5.6.100.0070.08321.00
5.6.90.0030.05721.00
5.6.80.0170.07020.40
5.6.70.0070.05320.43
5.6.60.0100.06720.41
5.6.50.0000.05020.32
5.6.40.0030.06020.41
5.6.30.0030.08320.31
5.6.20.0000.06320.30
5.6.10.0070.08020.31
5.6.00.0070.06720.36
5.5.360.0030.08320.38
5.5.350.0030.08320.45
5.5.340.0070.05020.86
5.5.330.0000.07020.86
5.5.320.0030.05720.89
5.5.310.0100.08020.87
5.5.300.0030.09020.81
5.5.290.0000.09020.90
5.5.280.0100.08320.86
5.5.270.0030.08020.93
5.5.260.0070.08720.86
5.5.250.0100.07720.74
5.5.240.0030.08020.31
5.5.230.0030.04720.25
5.5.220.0030.07320.13
5.5.210.0070.08020.15
5.5.200.0030.07720.27
5.5.190.0030.08720.10
5.5.180.0000.08720.24
5.5.160.0030.06019.95
5.5.150.0070.07720.25
5.5.140.0070.08020.09
5.5.130.0100.08019.99
5.5.120.0070.04720.06
5.5.110.0070.07719.97
5.5.100.0170.07320.08
5.5.90.0100.07720.16
5.5.80.0000.08020.06
5.5.70.0030.08020.06
5.5.60.0070.05320.05
5.5.50.0030.07020.15
5.5.40.0070.07320.14
5.5.30.0030.08319.95
5.5.20.0070.06720.15
5.5.10.0070.08020.09
5.5.00.0030.07719.97
5.4.450.0030.08319.51
5.4.440.0100.08019.46
5.4.430.0030.08319.16
5.4.420.0030.08719.48
5.4.410.0070.07319.23
5.4.400.0070.07319.23
5.4.390.0030.08319.09
5.4.380.0030.05019.05
5.4.370.0030.07319.09
5.4.360.0030.04019.11
5.4.350.0070.08019.03
5.4.340.0130.06719.14
5.4.320.0070.07319.24
5.4.310.0070.04319.09
5.4.300.0070.08019.16
5.4.290.0070.05019.09
5.4.280.0070.07318.89
5.4.270.0030.08019.04
5.4.260.0070.06719.06
5.4.250.0070.07018.87
5.4.240.0030.06318.89
5.4.230.0000.08319.16
5.4.220.0000.06319.03
5.4.210.0070.07719.12
5.4.200.0070.06718.84
5.4.190.0070.06319.11
5.4.180.0030.05319.16
5.4.170.0030.07719.11
5.4.160.0070.07719.07
5.4.150.0000.08019.01
5.4.140.0030.07716.41
5.4.130.0070.06716.45
5.4.120.0030.07316.40
5.4.110.0030.07316.44
5.4.100.0070.04716.39
5.4.90.0030.07716.50
5.4.80.0070.07016.25
5.4.70.0070.04316.31
5.4.60.0030.07316.36
5.4.50.0030.05716.48
5.4.40.0070.07016.35
5.4.30.0070.07016.24
5.4.20.0030.07316.25
5.4.10.0030.08016.33
5.4.00.0000.07315.90
5.3.290.0070.07014.73
5.3.280.0000.07714.72
5.3.270.0000.08714.57
5.3.260.0000.08714.59
5.3.250.0100.07314.68
5.3.240.0100.07014.67
5.3.230.0030.05014.74
5.3.220.0000.08014.50
5.3.210.0070.07314.49
5.3.200.0100.05314.46
5.3.190.0070.07314.59
5.3.180.0000.04314.55
5.3.170.0030.07314.68
5.3.160.0100.06714.62
5.3.150.0100.07314.68
5.3.140.0070.07314.60
5.3.130.0030.07714.61
5.3.120.0100.06014.56
5.3.110.0030.07714.64
5.3.100.0000.08014.16
5.3.90.0070.06313.96
5.3.80.0070.07313.91
5.3.70.0000.08014.05
5.3.60.0070.07314.14
5.3.50.0030.05313.99
5.3.40.0030.04714.02
5.3.30.0000.08013.91
5.3.20.0000.07313.75
5.3.10.0000.06713.72
5.3.00.0030.06313.54
5.2.170.0030.05012.27
5.2.160.0000.06312.27
5.2.150.0100.04312.27
5.2.140.0000.06712.27
5.2.130.0000.05312.27
5.2.120.0000.07012.27
5.2.110.0070.06012.27
5.2.100.0030.05712.27
5.2.90.0070.06012.27
5.2.80.0030.05012.27
5.2.70.0030.06312.27
5.2.60.0000.06312.27
5.2.50.0070.06012.27
5.2.40.0100.05012.27
5.2.30.0030.05012.27
5.2.20.0030.06012.27
5.2.10.0070.04012.29
5.2.00.0030.03712.29
5.1.60.0070.04712.29
5.1.50.0030.05712.29
5.1.40.0030.04312.29
5.1.30.0070.05012.29
5.1.20.0030.06012.29
5.1.10.0000.05712.29
5.1.00.0000.06012.29
5.0.50.0030.04312.29
5.0.40.0030.04312.29
5.0.30.0000.06712.29
5.0.20.0000.04712.29
5.0.10.0000.04712.29
5.0.00.0070.06012.29
4.4.90.0000.04012.27
4.4.80.0030.03312.27
4.4.70.0000.04012.28
4.4.60.0030.03712.29
4.4.50.0070.03012.29
4.4.40.0000.05312.29
4.4.30.0030.03712.29
4.4.20.0030.03712.29
4.4.10.0030.03012.29
4.4.00.0000.03712.29
4.3.110.0030.02712.29
4.3.100.0000.04012.29
4.3.90.0030.03012.29
4.3.80.0000.05712.29
4.3.70.0000.02712.29
4.3.60.0000.02712.29
4.3.50.0000.02712.29
4.3.40.0000.05012.29
4.3.30.0070.03312.29
4.3.20.0000.04012.29
4.3.10.0000.04012.29
4.3.00.0000.03712.29

preferences:
47.67 ms | 401 KiB | 5 Q