3v4l.org

run code in 300+ PHP versions simultaneously
<?php function round_to_four($number) { if($number <= 12) { $number = 12; } else { $number = ceil($number); if(!($number % 4 == 0)) $number += (4 - ($number % 4)); } return $number; } foreach(range(1, 21) as $i) { echo $i . ' => ' . round_to_four($i) . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/TJtnm
function name:  (null)
number of ops:  16
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 21
          3        DO_ICALL                                         $1      
          4      > FE_RESET_R                                       $2      $1, ->14
          5    > > FE_FETCH_R                                               $2, !0, ->14
   13     6    >   CONCAT                                           ~3      !0, '+%3D%3E+'
          7        INIT_FCALL                                               'round_to_four'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0  $4      
         10        CONCAT                                           ~5      ~3, $4
         11        CONCAT                                           ~6      ~5, '%0A'
         12        ECHO                                                     ~6
   12    13      > JMP                                                      ->5
         14    >   FE_FREE                                                  $2
   14    15      > RETURN                                                   1

Function round_to_four:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/TJtnm
function name:  round_to_four
number of ops:  18
compiled vars:  !0 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        IS_SMALLER_OR_EQUAL                                      !0, 12
          2      > JMPZ                                                     ~1, ->5
    4     3    >   ASSIGN                                                   !0, 12
    3     4      > JMP                                                      ->16
    6     5    >   INIT_FCALL                                               'ceil'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $3      
          8        ASSIGN                                                   !0, $3
    7     9        MOD                                              ~5      !0, 4
         10        IS_EQUAL                                         ~6      ~5, 0
         11        BOOL_NOT                                         ~7      ~6
         12      > JMPZ                                                     ~7, ->16
         13    >   MOD                                              ~8      !0, 4
         14        SUB                                              ~9      4, ~8
         15        ASSIGN_OP                                     1          !0, ~9
    9    16    > > RETURN                                                   !0
   10    17*     > RETURN                                                   null

End of function round_to_four

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.3 ms | 1018 KiB | 16 Q