3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_ean13($ean13) { if (strlen($ean13) != 13) return 1; // le code-barres doit contenir 13 caractères if (!is_numeric($ean13)) return 2; // le code-barres ne doit contenir que des chiffres // on prend chaque chiffre un par un // si son index (position dans la chaîne en commence à 0 au premier caractère) est impair // on triple sa valeur // on ajoute cette valeur à la somme totale for ($index = 0; $index < 12; $index ++) { $number = (int) $ean13[$index]; if (($index % 2) != 0) $number *= 3; $sum += $number; } $key = $ean13[12]; // clé de contrôle égale au dernier chiffre // la clé de contrôle doit être égale à : 10 - (reste de la division de la somme des 12 premiers chiffres) if (10 - ($sum % 10) != $key) return 3; else return 0; } echo is_ean13(7330510000000);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hf4PM
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'is_ean13'
          1        SEND_VAL                                                 7330510000000
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function is_ean13:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 13
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 13
Branch analysis from position: 24
Branch analysis from position: 13
Branch analysis from position: 20
filename:       /in/hf4PM
function name:  is_ean13
number of ops:  34
compiled vars:  !0 = $ean13, !1 = $index, !2 = $number, !3 = $sum, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        STRLEN                                           ~5      !0
          2        IS_NOT_EQUAL                                             ~5, 13
          3      > JMPZ                                                     ~6, ->5
          4    > > RETURN                                                   1
    6     5    >   INIT_FCALL                                               'is_numeric'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $7      
          8        BOOL_NOT                                         ~8      $7
          9      > JMPZ                                                     ~8, ->11
         10    > > RETURN                                                   2
   13    11    >   ASSIGN                                                   !1, 0
         12      > JMP                                                      ->22
   15    13    >   FETCH_DIM_R                                      ~10     !0, !1
         14        CAST                                          4  ~11     ~10
         15        ASSIGN                                                   !2, ~11
   16    16        MOD                                              ~13     !1, 2
         17        IS_NOT_EQUAL                                             ~13, 0
         18      > JMPZ                                                     ~14, ->20
         19    >   ASSIGN_OP                                     3          !2, 3
   17    20    >   ASSIGN_OP                                     1          !3, !2
   13    21        PRE_INC                                                  !1
         22    >   IS_SMALLER                                               !1, 12
         23      > JMPNZ                                                    ~18, ->13
   20    24    >   FETCH_DIM_R                                      ~19     !0, 12
         25        ASSIGN                                                   !4, ~19
   23    26        MOD                                              ~21     !3, 10
         27        SUB                                              ~22     10, ~21
         28        IS_NOT_EQUAL                                             !4, ~22
         29      > JMPZ                                                     ~23, ->32
         30    > > RETURN                                                   3
         31*       JMP                                                      ->33
         32    > > RETURN                                                   0
   24    33*     > RETURN                                                   null

End of function is_ean13

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.7 ms | 1403 KiB | 16 Q