3v4l.org

run code in 300+ PHP versions simultaneously
<?php function count_digits($digit, $base) { // TODO: add type validation return $digit >= $base ? 1 + count_digits($digit / $base, $base) : 1; } $digit = 1554; $tries = 10000; var_dump(count_digits($digit, 2), decbin($digit));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2jjdU
function name:  (null)
number of ops:  14
compiled vars:  !0 = $digit, !1 = $tries
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 1554
    9     1        ASSIGN                                                   !1, 10000
   11     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'count_digits'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 2
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        INIT_FCALL                                               'decbin'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
         11        SEND_VAR                                                 $5
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function count_digits:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2jjdU
function name:  count_digits
number of ops:  15
compiled vars:  !0 = $digit, !1 = $base
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        IS_SMALLER_OR_EQUAL                                      !1, !0
          3      > JMPZ                                                     ~2, ->12
          4    >   INIT_FCALL_BY_NAME                                       'count_digits'
          5        DIV                                              ~3      !0, !1
          6        SEND_VAL_EX                                              ~3
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $4      
          9        ADD                                              ~5      1, $4
         10        QM_ASSIGN                                        ~6      ~5
         11      > JMP                                                      ->13
         12    >   QM_ASSIGN                                        ~6      1
         13    > > RETURN                                                   ~6
    6    14*     > RETURN                                                   null

End of function count_digits

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.49 ms | 1390 KiB | 18 Q