3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_divisible_by_3($n){ $digits = str_split($n); $total = 0; foreach ($digits as $digit) { $total += $digit; } if ($total == 3 || ($total % 3 == 0) ){ return true; } return false; } $num = 110001; if (is_divisible_by_3($num)){ echo $num, " is divisible by three."; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/83jZU
function name:  (null)
number of ops:  8
compiled vars:  !0 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, 110001
   16     1        INIT_FCALL                                               'is_divisible_by_3'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4      > JMPZ                                                     $2, ->7
   17     5    >   ECHO                                                     !0
          6        ECHO                                                     '+is+divisible+by+three.'
   18     7    > > RETURN                                                   1

Function is_divisible_by_3:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 10
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 10
filename:       /in/83jZU
function name:  is_divisible_by_3
number of ops:  20
compiled vars:  !0 = $n, !1 = $digits, !2 = $total, !3 = $digit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'str_split'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
    5     5        ASSIGN                                                   !2, 0
    6     6      > FE_RESET_R                                       $7      !1, ->10
          7    > > FE_FETCH_R                                               $7, !3, ->10
    7     8    >   ASSIGN_OP                                     1          !2, !3
    6     9      > JMP                                                      ->7
         10    >   FE_FREE                                                  $7
    9    11        IS_EQUAL                                         ~9      !2, 3
         12      > JMPNZ_EX                                         ~9      ~9, ->16
         13    >   MOD                                              ~10     !2, 3
         14        IS_EQUAL                                         ~11     ~10, 0
         15        BOOL                                             ~9      ~11
         16    > > JMPZ                                                     ~9, ->18
   10    17    > > RETURN                                                   <true>
   12    18    > > RETURN                                                   <false>
   13    19*     > RETURN                                                   null

End of function is_divisible_by_3

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.03 ms | 1399 KiB | 16 Q