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; $i++; } } print_r(fizzbuzz());
Output for git.master, git.master_jit, rfc.property-hooks
$i = 1 $offset = 1 $iterations = 100$i = 2 $offset = 1 $iterations = 100$i = 3 $offset = 1 $iterations = 100$i = 4 $offset = 1 $iterations = 100$i = 5 $offset = 1 $iterations = 100$i = 6 $offset = 1 $iterations = 100$i = 7 $offset = 1 $iterations = 100$i = 8 $offset = 1 $iterations = 100$i = 9 $offset = 1 $iterations = 100$i = 10 $offset = 1 $iterations = 100$i = 11 $offset = 1 $iterations = 100$i = 12 $offset = 1 $iterations = 100$i = 13 $offset = 1 $iterations = 100$i = 14 $offset = 1 $iterations = 100$i = 15 $offset = 1 $iterations = 100$i = 16 $offset = 1 $iterations = 100$i = 17 $offset = 1 $iterations = 100$i = 18 $offset = 1 $iterations = 100$i = 19 $offset = 1 $iterations = 100$i = 20 $offset = 1 $iterations = 100$i = 21 $offset = 1 $iterations = 100$i = 22 $offset = 1 $iterations = 100$i = 23 $offset = 1 $iterations = 100$i = 24 $offset = 1 $iterations = 100$i = 25 $offset = 1 $iterations = 100$i = 26 $offset = 1 $iterations = 100$i = 27 $offset = 1 $iterations = 100$i = 28 $offset = 1 $iterations = 100$i = 29 $offset = 1 $iterations = 100$i = 30 $offset = 1 $iterations = 100$i = 31 $offset = 1 $iterations = 100$i = 32 $offset = 1 $iterations = 100$i = 33 $offset = 1 $iterations = 100$i = 34 $offset = 1 $iterations = 100$i = 35 $offset = 1 $iterations = 100$i = 36 $offset = 1 $iterations = 100$i = 37 $offset = 1 $iterations = 100$i = 38 $offset = 1 $iterations = 100$i = 39 $offset = 1 $iterations = 100$i = 40 $offset = 1 $iterations = 100$i = 41 $offset = 1 $iterations = 100$i = 42 $offset = 1 $iterations = 100$i = 43 $offset = 1 $iterations = 100$i = 44 $offset = 1 $iterations = 100$i = 45 $offset = 1 $iterations = 100$i = 46 $offset = 1 $iterations = 100$i = 47 $offset = 1 $iterations = 100$i = 48 $offset = 1 $iterations = 100$i = 49 $offset = 1 $iterations = 100$i = 50 $offset = 1 $iterations = 100$i = 51 $offset = 1 $iterations = 100$i = 52 $offset = 1 $iterations = 100$i = 53 $offset = 1 $iterations = 100$i = 54 $offset = 1 $iterations = 100$i = 55 $offset = 1 $iterations = 100$i = 56 $offset = 1 $iterations = 100$i = 57 $offset = 1 $iterations = 100$i = 58 $offset = 1 $iterations = 100$i = 59 $offset = 1 $iterations = 100$i = 60 $offset = 1 $iterations = 100$i = 61 $offset = 1 $iterations = 100$i = 62 $offset = 1 $iterations = 100$i = 63 $offset = 1 $iterations = 100$i = 64 $offset = 1 $iterations = 100$i = 65 $offset = 1 $iterations = 100$i = 66 $offset = 1 $iterations = 100$i = 67 $offset = 1 $iterations = 100$i = 68 $offset = 1 $iterations = 100$i = 69 $offset = 1 $iterations = 100$i = 70 $offset = 1 $iterations = 100$i = 71 $offset = 1 $iterations = 100$i = 72 $offset = 1 $iterations = 100$i = 73 $offset = 1 $iterations = 100$i = 74 $offset = 1 $iterations = 100$i = 75 $offset = 1 $iterations = 100$i = 76 $offset = 1 $iterations = 100$i = 77 $offset = 1 $iterations = 100$i = 78 $offset = 1 $iterations = 100$i = 79 $offset = 1 $iterations = 100$i = 80 $offset = 1 $iterations = 100$i = 81 $offset = 1 $iterations = 100$i = 82 $offset = 1 $iterations = 100$i = 83 $offset = 1 $iterations = 100$i = 84 $offset = 1 $iterations = 100$i = 85 $offset = 1 $iterations = 100$i = 86 $offset = 1 $iterations = 100$i = 87 $offset = 1 $iterations = 100$i = 88 $offset = 1 $iterations = 100$i = 89 $offset = 1 $iterations = 100$i = 90 $offset = 1 $iterations = 100$i = 91 $offset = 1 $iterations = 100$i = 92 $offset = 1 $iterations = 100$i = 93 $offset = 1 $iterations = 100$i = 94 $offset = 1 $iterations = 100$i = 95 $offset = 1 $iterations = 100$i = 96 $offset = 1 $iterations = 100$i = 97 $offset = 1 $iterations = 100$i = 98 $offset = 1 $iterations = 100$i = 99 $offset = 1 $iterations = 100$i = 100 $offset = 1 $iterations = 100

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
59.31 ms | 409 KiB | 8 Q