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; while($i < ($offset + $iterations)){ if($i % $fizzbuzz_int == 0){ echo $fizzbuzz;} elseif($i % $buzz_int == 0){ echo $buzz;} elseif($i % $fizz_int == 0){ echo $fizz;} else{ echo $i;} echo "\n"; $i++; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UPEFb
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E > > RETURN                                                   1

Function fizzbuzz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 10
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 10
Branch analysis from position: 31
Branch analysis from position: 10
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 10
Branch analysis from position: 31
Branch analysis from position: 10
filename:       /in/UPEFb
function name:  fizzbuzz
number of ops:  32
compiled vars:  !0 = $iterations, !1 = $offset, !2 = $fizz, !3 = $buzz, !4 = $fizzbuzz, !5 = $fizz_int, !6 = $buzz_int, !7 = $fizzbuzz_int, !8 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV_INIT                                        !0      100
          1        RECV_INIT                                        !1      1
          2        RECV_INIT                                        !2      'fizz'
          3        RECV_INIT                                        !3      'buzz'
          4        RECV_INIT                                        !4      'fizzbuzz'
          5        RECV_INIT                                        !5      3
          6        RECV_INIT                                        !6      5
          7        RECV_INIT                                        !7      15
   30     8        ASSIGN                                                   !8, !1
   31     9      > JMP                                                      ->28
   32    10    >   MOD                                              ~10     !8, !7
         11        IS_EQUAL                                                 ~10, 0
         12      > JMPZ                                                     ~11, ->15
         13    >   ECHO                                                     !4
         14      > JMP                                                      ->26
   33    15    >   MOD                                              ~12     !8, !6
         16        IS_EQUAL                                                 ~12, 0
         17      > JMPZ                                                     ~13, ->20
         18    >   ECHO                                                     !3
         19      > JMP                                                      ->26
   34    20    >   MOD                                              ~14     !8, !5
         21        IS_EQUAL                                                 ~14, 0
         22      > JMPZ                                                     ~15, ->25
         23    >   ECHO                                                     !2
         24      > JMP                                                      ->26
   35    25    >   ECHO                                                     !8
   36    26    >   ECHO                                                     '%0A'
   37    27        PRE_INC                                                  !8
   31    28    >   ADD                                              ~17     !1, !0
         29        IS_SMALLER                                               !8, ~17
         30      > JMPNZ                                                    ~18, ->10
   39    31    > > RETURN                                                   null

End of function fizzbuzz

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.76 ms | 1403 KiB | 13 Q