3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ean_checksum($eancode) { $result = false; if(strlen($eancode) == 13) { $check_code = substr($eancode, 12, 1); $eancode = substr($eancode, 0, 12); $oddsum=0; $evensum=0; $total=0; $eanvalue=$eancode; $finalean = strrev(substr($eanvalue,0,12)); for($i=0;$i<strlen($finalean);$i++) { if(($i % 2) == 0) { $oddsum += intval($finalean[$i]); } else { $evensum += intval($finalean[$i]); } } $total = ($oddsum * 3) + $evensum; $check = intval(10 - ceil($total % 10.0)) %10; if($check == $check_code) { $result = true; } } return $result; } var_dump('3603912289411');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nJHWt
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 '3603912289411'
          2        DO_ICALL                                                 
          3      > RETURN                                                   1

Function ean_checksum:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 60
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 32
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 60
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 39
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 32
Branch analysis from position: 46
Branch analysis from position: 32
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 32
Branch analysis from position: 46
Branch analysis from position: 32
Branch analysis from position: 60
filename:       /in/nJHWt
function name:  ean_checksum
number of ops:  62
compiled vars:  !0 = $eancode, !1 = $result, !2 = $check_code, !3 = $oddsum, !4 = $evensum, !5 = $total, !6 = $eanvalue, !7 = $finalean, !8 = $i, !9 = $check
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, <false>
    4     2        STRLEN                                           ~11     !0
          3        IS_EQUAL                                                 ~11, 13
          4      > JMPZ                                                     ~12, ->60
    5     5    >   INIT_FCALL                                               'substr'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 12
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $13     
         10        ASSIGN                                                   !2, $13
    6    11        INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 0
         14        SEND_VAL                                                 12
         15        DO_ICALL                                         $15     
         16        ASSIGN                                                   !0, $15
    8    17        ASSIGN                                                   !3, 0
    9    18        ASSIGN                                                   !4, 0
   10    19        ASSIGN                                                   !5, 0
   11    20        ASSIGN                                                   !6, !0
   12    21        INIT_FCALL                                               'strrev'
         22        INIT_FCALL                                               'substr'
         23        SEND_VAR                                                 !6
         24        SEND_VAL                                                 0
         25        SEND_VAL                                                 12
         26        DO_ICALL                                         $21     
         27        SEND_VAR                                                 $21
         28        DO_ICALL                                         $22     
         29        ASSIGN                                                   !7, $22
   14    30        ASSIGN                                                   !8, 0
         31      > JMP                                                      ->43
   15    32    >   MOD                                              ~25     !8, 2
         33        IS_EQUAL                                                 ~25, 0
         34      > JMPZ                                                     ~26, ->39
   16    35    >   FETCH_DIM_R                                      ~27     !7, !8
         36        CAST                                          4  ~28     ~27
         37        ASSIGN_OP                                     1          !3, ~28
         38      > JMP                                                      ->42
   19    39    >   FETCH_DIM_R                                      ~30     !7, !8
         40        CAST                                          4  ~31     ~30
         41        ASSIGN_OP                                     1          !4, ~31
   14    42    >   PRE_INC                                                  !8
         43    >   STRLEN                                           ~34     !7
         44        IS_SMALLER                                               !8, ~34
         45      > JMPNZ                                                    ~35, ->32
   22    46    >   MUL                                              ~36     !3, 3
         47        ADD                                              ~37     ~36, !4
         48        ASSIGN                                                   !5, ~37
   24    49        INIT_FCALL                                               'ceil'
         50        MOD                                              ~39     !5, 10
         51        SEND_VAL                                                 ~39
         52        DO_ICALL                                         $40     
         53        SUB                                              ~41     10, $40
         54        CAST                                          4  ~42     ~41
         55        MOD                                              ~43     ~42, 10
         56        ASSIGN                                                   !9, ~43
   25    57        IS_EQUAL                                                 !9, !2
         58      > JMPZ                                                     ~45, ->60
   26    59    >   ASSIGN                                                   !1, <true>
   29    60    > > RETURN                                                   !1
   30    61*     > RETURN                                                   null

End of function ean_checksum

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.68 ms | 1392 KiB | 21 Q