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[] = $fizzbuzz;} elseif($i % $buzz_int == 0){ $ret[] = $buzz;} elseif($i % $fizz_int == 0){ $ret[] = $fizz;} else{ $ret[] = $i;} echo '$i = ' . $i . ' $offset = ' . $offset . ' $iterations = ' . $iterations . ' $ret this time is ' . $ret[($iterations - $offset - $i)]; $i++; } } 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.0100.01418.81
8.3.50.0100.00821.27
8.3.40.0060.01018.79
8.3.30.0070.00720.39
8.3.20.0030.00520.70
8.3.10.0080.00021.13
8.3.00.0040.00423.61
8.2.180.0160.00616.50
8.2.170.0170.00322.96
8.2.160.0070.01120.35
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00421.13
8.2.110.0040.00721.11
8.2.100.0090.00318.34
8.2.90.0030.00519.17
8.2.80.0000.00917.97
8.2.70.0040.00417.75
8.2.60.0040.00417.93
8.2.50.0000.00818.22
8.2.40.0000.00720.61
8.2.30.0030.00619.39
8.2.20.0080.00017.70
8.2.10.0060.00317.86
8.2.00.0040.00417.84
8.1.280.0120.00325.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0060.00322.56
8.1.230.0060.00620.39
8.1.220.0080.00017.74
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0060.00317.23
8.1.180.0040.00418.10
8.1.170.0070.00318.65
8.1.160.0040.00418.92
8.1.150.0000.00818.70
8.1.140.0080.00017.48
8.1.130.0030.00317.81
8.1.120.0000.00817.55
8.1.110.0050.00217.43
8.1.100.0060.00317.50
8.1.90.0000.00717.54
8.1.80.0040.00417.38
8.1.70.0040.00417.36
8.1.60.0030.00617.66
8.1.50.0030.00617.41
8.1.40.0000.00817.45
8.1.30.0030.00517.51
8.1.20.0000.00817.75
8.1.10.0050.00317.60
8.1.00.0040.00417.44
8.0.300.0000.00818.77
8.0.290.0040.00416.88
8.0.280.0000.00718.51
8.0.270.0080.00017.20
8.0.260.0030.00316.98
8.0.250.0080.00016.95
8.0.240.0040.00417.05
8.0.230.0070.00017.08
8.0.220.0040.00416.95
8.0.210.0030.00517.07
8.0.200.0050.00316.95
8.0.190.0030.00516.94
8.0.180.0030.00616.91
8.0.170.0000.00717.00
8.0.160.0000.00817.11
8.0.150.0000.00816.93
8.0.140.0060.00316.97
8.0.130.0030.00513.45
8.0.120.0030.00516.98
8.0.110.0080.00017.03
8.0.100.0070.00017.01
8.0.90.0040.00416.84
8.0.80.0100.00716.95
8.0.70.0040.00416.99
8.0.60.0000.00816.86
8.0.50.0040.00416.94
8.0.30.0080.01217.32
8.0.20.0110.00817.40
8.0.10.0040.00416.97
8.0.00.0130.00716.79
7.4.330.0000.00616.77
7.4.320.0000.00616.51
7.4.300.0020.00516.66
7.4.290.0070.00016.67
7.4.280.0000.00816.62
7.4.270.0030.00316.54
7.4.260.0030.00313.32
7.4.250.0060.00316.61
7.4.240.0030.00516.53
7.4.230.0030.00316.57
7.4.220.0100.01616.48
7.4.210.0130.00416.59
7.4.200.0000.00716.69
7.4.190.0040.00416.69
7.4.160.0150.00316.49
7.4.150.0120.00617.40
7.4.140.0130.01117.86
7.4.130.0080.00916.49
7.4.120.0140.00916.70
7.4.110.0100.00716.50
7.4.100.0090.00916.48
7.4.90.0100.01016.77
7.4.80.0150.00419.39
7.4.70.0110.01416.70
7.4.60.0150.00416.66
7.4.50.0000.00816.34
7.4.40.0110.00722.77
7.4.30.0060.01316.54
7.4.10.0060.00714.94
7.4.00.0090.00714.92
7.3.330.0000.00513.51
7.3.320.0000.00613.43
7.3.310.0080.00016.39
7.3.300.0040.00416.40
7.3.290.0070.00816.39
7.3.280.0110.00916.42
7.3.270.0090.00917.40
7.3.260.0140.00718.24
7.3.250.0110.00916.62
7.3.240.0170.00416.40
7.3.230.0110.01116.49
7.3.210.0150.00816.42
7.3.200.0230.00019.39
7.3.190.0120.01316.55
7.3.180.0130.00516.34
7.3.170.0120.00316.50
7.3.160.0070.01016.56
7.3.130.0130.00315.15
7.3.120.0110.00614.96
7.3.110.0100.01014.79
7.3.100.0100.00314.73
7.3.90.0090.00614.87
7.3.80.0000.01114.84
7.3.70.0030.00614.85
7.3.60.0040.00414.74
7.3.50.0030.00714.93
7.3.40.0030.01414.60
7.3.30.0030.00614.88
7.3.20.0060.00916.70
7.3.10.0030.01316.67
7.3.00.0070.00416.49
7.2.330.0090.00916.88
7.2.320.0130.01016.73
7.2.310.0070.01016.54
7.2.300.0090.01716.56
7.2.290.0100.00716.65
7.2.260.0060.01215.00
7.2.250.0110.00715.27
7.2.240.0030.01015.02
7.2.230.0080.00614.97
7.2.220.0030.00715.24
7.2.210.0000.01414.85
7.2.200.0030.00715.08
7.2.190.0090.00615.20
7.2.180.0060.00814.84
7.2.170.0030.01015.20
7.2.160.0070.01115.23
7.2.150.0030.01317.05
7.2.140.0070.01016.75
7.2.130.0070.00716.90
7.2.120.0120.00016.77
7.2.110.0040.01116.84
7.2.100.0140.00317.06
7.2.90.0040.01217.11
7.2.80.0140.00316.80
7.2.70.0060.00316.97
7.2.60.0030.01016.85
7.2.50.0000.01216.77
7.2.40.0070.00416.95
7.2.30.0060.00616.67
7.2.20.0070.01017.01
7.2.10.0120.00617.03
7.2.00.0060.00718.16
7.1.330.0080.00415.97
7.1.320.0070.00715.90
7.1.310.0060.00615.72
7.1.300.0030.01015.56
7.1.290.0040.00815.97
7.1.280.0000.01415.91
7.1.270.0070.00715.76
7.1.260.0060.01015.72
7.1.250.0030.01015.75
7.1.240.0030.01215.85
7.1.230.0090.00015.94
7.1.220.0060.00315.63
7.1.210.0040.00815.68
7.1.200.0000.01615.82
7.1.190.0110.00415.99
7.1.180.0070.00715.75
7.1.170.0000.01715.62
7.1.160.0000.01415.85
7.1.150.0030.01015.77
7.1.140.0070.00715.63
7.1.130.0060.01215.87
7.1.120.0040.00715.77
7.1.110.0060.00915.97
7.1.100.0070.00716.90
7.1.90.0100.00715.78
7.1.80.0110.00415.84
7.1.70.0040.00316.47
7.1.60.0080.01117.44
7.1.50.0050.01216.32
7.1.40.0040.01115.60
7.1.30.0070.00715.92
7.1.20.0060.00615.53
7.1.10.0080.00615.79
7.1.00.0050.04119.06
7.0.330.0110.00015.24
7.0.320.0030.01215.25
7.0.310.0090.00315.11
7.0.300.0000.01515.31
7.0.290.0030.01515.28
7.0.280.0040.01115.50
7.0.270.0030.01315.38
7.0.260.0030.01015.40
7.0.250.0030.00715.21
7.0.240.0070.00715.42
7.0.230.0070.00715.21
7.0.220.0100.00715.66
7.0.210.0080.00815.32
7.0.200.0020.01115.97
7.0.190.0040.00715.51
7.0.180.0080.00415.47
7.0.170.0040.00915.45
7.0.160.0120.00415.45
7.0.150.0090.00915.55
7.0.140.0050.03918.76
7.0.130.0040.00415.36
7.0.120.0000.01315.43
7.0.110.0040.01015.32
7.0.100.0040.01215.48
7.0.90.0030.01415.53
7.0.80.0040.00815.51
7.0.70.0070.04018.52
7.0.60.0070.03918.54
7.0.50.0050.04218.82
7.0.40.0070.04416.77
7.0.30.0070.03116.70
7.0.20.0030.03016.75
7.0.10.0050.02316.66
7.0.00.0120.04016.80
5.6.400.0040.01114.32
5.6.390.0100.00314.33
5.6.380.0060.00914.34
5.6.370.0070.01014.11
5.6.360.0030.01414.87
5.6.350.0040.00814.41
5.6.340.0070.00714.75
5.6.330.0060.01214.52
5.6.320.0040.01514.38
5.6.310.0140.00314.44
5.6.300.0110.00814.72
5.6.290.0070.01114.64
5.6.280.0060.03817.84
5.6.270.0090.00314.63
5.6.260.0070.01014.53
5.6.250.0080.00814.84
5.6.240.0070.01114.59
5.6.230.0040.00814.39
5.6.220.0060.04617.46
5.6.210.0100.03517.47
5.6.200.0080.03617.69
5.6.190.0090.04717.78
5.6.180.0050.04417.58
5.6.170.0070.04417.75
5.6.160.0080.04517.70
5.6.150.0060.04217.87
5.6.140.0070.04517.87
5.6.130.0060.04017.74
5.6.120.0160.03617.74
5.6.110.0080.04517.72
5.6.100.0060.04417.84
5.6.90.0050.05017.82
5.6.80.0060.04017.28
5.6.70.0070.03817.37
5.6.60.0050.04517.33
5.6.50.0100.03917.37
5.6.40.0100.04217.21
5.6.30.0000.04817.44
5.6.20.0110.03617.41
5.6.10.0030.04217.33
5.6.00.0030.04517.34
5.5.380.0070.01114.73
5.5.370.0000.01314.13
5.5.360.0080.03317.35
5.5.350.0030.04917.29
5.5.340.0090.04117.43
5.5.330.0080.03217.47
5.5.320.0030.04717.56
5.5.310.0070.04317.50
5.5.300.0090.04517.52
5.5.290.0110.04117.55
5.5.280.0070.04517.65
5.5.270.0050.04017.47
5.5.260.0020.02717.76
5.5.250.0050.04517.67
5.5.240.0060.03717.35
5.5.230.0080.04517.26
5.5.220.0050.04717.22
5.5.210.0050.04317.16
5.5.200.0070.04117.38
5.5.190.0070.04017.35
5.5.180.0050.04517.29
5.5.170.0100.00314.22
5.5.160.0070.02617.36
5.5.150.0070.04517.18
5.5.140.0130.03517.07
5.5.130.0050.04817.19
5.5.120.0050.04017.14
5.5.110.0060.04317.19
5.5.100.0060.04217.00
5.5.90.0060.04417.17
5.5.80.0030.04417.23
5.5.70.0050.04317.20
5.5.60.0050.04217.30
5.5.50.0070.03017.24
5.5.40.0060.04317.22
5.5.30.0100.03817.31
5.5.20.0050.03517.27
5.5.10.0060.04517.25
5.5.00.0030.04517.04
5.4.450.0030.03015.43
5.4.440.0070.04315.35
5.4.430.0020.03315.22
5.4.420.0030.04015.44
5.4.410.0070.03815.22
5.4.400.0070.03015.18
5.4.390.0070.04315.20
5.4.380.0070.04015.11
5.4.370.0080.03815.15
5.4.360.0110.03315.13
5.4.350.0050.03215.17
5.4.340.0050.03515.20
5.4.330.0060.00911.05
5.4.320.0070.04015.11
5.4.310.0020.03615.10
5.4.300.0030.02714.94
5.4.290.0070.03914.87
5.4.280.0070.03815.21
5.4.270.0060.03815.14
5.4.260.0050.03515.06
5.4.250.0070.03515.02
5.4.240.0120.03715.01
5.4.230.0020.04215.14
5.4.220.0090.03714.97
5.4.210.0090.03915.14
5.4.200.0030.04515.03
5.4.190.0130.03515.03
5.4.180.0120.03815.19
5.4.170.0070.04015.11
5.4.160.0070.03815.11
5.4.150.0060.04114.97
5.4.140.0040.03413.77
5.4.130.0030.04113.94
5.4.120.0040.03913.85
5.4.110.0060.03813.94
5.4.100.0050.03813.79
5.4.90.0090.03213.78
5.4.80.0020.03613.67
5.4.70.0030.04013.80
5.4.60.0030.02613.87
5.4.50.0070.02313.76
5.4.40.0050.03713.92
5.4.30.0070.03313.83
5.4.20.0060.02013.86
5.4.10.0070.04113.85
5.4.00.0030.02813.49
5.3.290.0080.03512.72
5.3.280.0070.03712.65
5.3.270.0070.03512.66
5.3.260.0000.04812.65
5.3.250.0070.03812.63
5.3.240.0080.04012.63
5.3.230.0030.04112.59
5.3.220.0020.03912.54
5.3.210.0030.04312.68
5.3.200.0030.04112.49
5.3.190.0030.03312.57
5.3.180.0060.03812.71
5.3.170.0030.04112.74
5.3.160.0040.03712.67
5.3.150.0050.04012.52
5.3.140.0030.04112.73
5.3.130.0020.04012.70
5.3.120.0060.02612.74
5.3.110.0060.03712.64
5.3.100.0030.03712.45
5.3.90.0050.03212.36
5.3.80.0050.04012.20
5.3.70.0070.03112.31
5.3.60.0060.02512.27
5.3.50.0030.04012.33
5.3.40.0020.03612.27
5.3.30.0030.04012.18
5.3.20.0050.04012.11
5.3.10.0070.03512.10
5.3.00.0010.02512.06
5.2.170.0070.06013.31
5.2.160.0030.04713.31
5.2.150.0030.06013.31
5.2.140.0000.05313.31
5.2.130.0030.05313.31
5.2.120.0070.03013.31
5.2.110.0000.06713.31
5.2.100.0070.03313.31
5.2.90.0000.06313.31
5.2.80.0100.05713.31
5.2.70.0030.04713.31
5.2.60.0070.05013.31
5.2.50.0000.05013.31
5.2.40.0030.06313.31
5.2.30.0070.06013.31
5.2.20.0070.04313.31
5.2.10.0030.06013.31
5.2.00.0000.06013.31
5.1.60.0000.05713.31
5.1.50.0000.05313.31
5.1.40.0000.05713.31
5.1.30.0030.04713.31
5.1.20.0070.05313.31
5.1.10.0070.05713.31
5.1.00.0030.05313.31
5.0.50.0030.03013.31
5.0.40.0030.03013.31
5.0.30.0070.05713.31
5.0.20.0030.03313.31
5.0.10.0000.04713.31
5.0.00.0000.06713.31
4.4.90.0000.04013.31
4.4.80.0070.03313.31
4.4.70.0000.04013.31
4.4.60.0070.03313.31
4.4.50.0030.03013.31
4.4.40.0000.05713.31
4.4.30.0030.03013.31
4.4.20.0000.04013.31
4.4.10.0000.03313.31
4.4.00.0000.06013.31
4.3.110.0000.03713.31
4.3.100.0000.02313.31
4.3.90.0000.03313.31
4.3.80.0030.05313.31
4.3.70.0070.03013.31
4.3.60.0030.03313.31
4.3.50.0100.03013.31
4.3.40.0030.05013.31
4.3.30.0000.03313.31
4.3.20.0030.03313.31
4.3.10.0070.03013.31
4.3.00.0000.02713.31

preferences:
46 ms | 401 KiB | 5 Q