3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* the difference in days between today and '$delay' number business days (M-F). yes. */ function g($current_day, $delay) { /* wraps around to the next day which is '$delay' number of business days from today lol, math */ if(($current_day+$delay) > 5) return abs((7+(((min($current_day, 5)+($delay-1))%5)+1)) - $current_day); else return $delay; } function f($current_day, $delay) { return abs((7+(((min($current_day, 5)+($delay-1))%5)+1)) - $current_day); } for($i = 1; $i < 8; $i++) printf("\tf(%d, 1) => %d\n", $i, f($i, 1)); printf("\n\n\n\n"); for($i = 1; $i < 8; $i++) printf("\tf(%d, 2) => %d\n", $i, f($i, 2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 2
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
Branch analysis from position: 19
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 2
Branch analysis from position: 14
Branch analysis from position: 2
filename:       /in/KTBBb
function name:  (null)
number of ops:  32
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, 1
          1      > JMP                                                      ->12
   27     2    >   INIT_FCALL                                               'printf'
          3        SEND_VAL                                                 '%09f%28%25d%2C+1%29+%3D%3E+%25d%0A'
          4        SEND_VAR                                                 !0
          5        INIT_FCALL                                               'f'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 1
          8        DO_FCALL                                      0  $2      
          9        SEND_VAR                                                 $2
         10        DO_ICALL                                                 
   26    11        PRE_INC                                                  !0
         12    >   IS_SMALLER                                               !0, 8
         13      > JMPNZ                                                    ~5, ->2
   29    14    >   INIT_FCALL                                               'printf'
         15        SEND_VAL                                                 '%0A%0A%0A%0A'
         16        DO_ICALL                                                 
   31    17        ASSIGN                                                   !0, 1
         18      > JMP                                                      ->29
   32    19    >   INIT_FCALL                                               'printf'
         20        SEND_VAL                                                 '%09f%28%25d%2C+2%29+%3D%3E+%25d%0A'
         21        SEND_VAR                                                 !0
         22        INIT_FCALL                                               'f'
         23        SEND_VAR                                                 !0
         24        SEND_VAL                                                 2
         25        DO_FCALL                                      0  $8      
         26        SEND_VAR                                                 $8
         27        DO_ICALL                                                 
   31    28        PRE_INC                                                  !0
         29    >   IS_SMALLER                                               !0, 8
         30      > JMPNZ                                                    ~11, ->19
   32    31    > > RETURN                                                   1

Function g:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KTBBb
function name:  g
number of ops:  22
compiled vars:  !0 = $current_day, !1 = $delay
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        ADD                                              ~2      !0, !1
          3        IS_SMALLER                                               5, ~2
          4      > JMPZ                                                     ~3, ->20
   16     5    >   INIT_FCALL                                               'abs'
          6        INIT_FCALL                                               'min'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 5
          9        DO_ICALL                                         $4      
         10        SUB                                              ~5      !1, 1
         11        ADD                                              ~6      $4, ~5
         12        MOD                                              ~7      ~6, 5
         13        ADD                                              ~8      ~7, 1
         14        ADD                                              ~9      7, ~8
         15        SUB                                              ~10     ~9, !0
         16        SEND_VAL                                                 ~10
         17        DO_ICALL                                         $11     
         18      > RETURN                                                   $11
         19*       JMP                                                      ->21
   18    20    > > RETURN                                                   !1
   19    21*     > RETURN                                                   null

End of function g

Function f:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KTBBb
function name:  f
number of ops:  17
compiled vars:  !0 = $current_day, !1 = $delay
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   23     2        INIT_FCALL                                               'abs'
          3        INIT_FCALL                                               'min'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 5
          6        DO_ICALL                                         $2      
          7        SUB                                              ~3      !1, 1
          8        ADD                                              ~4      $2, ~3
          9        MOD                                              ~5      ~4, 5
         10        ADD                                              ~6      ~5, 1
         11        ADD                                              ~7      7, ~6
         12        SUB                                              ~8      ~7, !0
         13        SEND_VAL                                                 ~8
         14        DO_ICALL                                         $9      
         15      > RETURN                                                   $9
   24    16*     > RETURN                                                   null

End of function f

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.52 ms | 1403 KiB | 21 Q