3v4l.org

run code in 300+ PHP versions simultaneously
<?php function checkIBAN(string $iban): bool { // Normalize input (remove spaces and make uppercase) $iban = strtoupper(str_replace(' ', '', $iban)); if (!preg_match('/^([A-Z]{2})(\d{2})([A-Z\d]{1,30})$/', $iban, $segments)) { return false; } [, $country, $check, $account] = $segments; $digits = str_split(strtr($account . $country, array_combine(range('A', 'Z'), range(10, 35))) . '00'); $first = array_shift($digits); $checksum = array_reduce( $digits, function ($carry, $int) { $carry = ($carry * 10 + (int)$int) % 97; return $carry; }, (int)$first ); return (98 - $checksum) == $check; } var_export(checkIBAN('GB29NWBK60161331926819'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fDgfo
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'var_export'
          1        INIT_FCALL                                               'checkiban'
          2        SEND_VAL                                                 'GB29NWBK60161331926819'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function checkiban:
Finding entry points
Branch analysis from position: 0
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
filename:       /in/fDgfo
function name:  checkIBAN
number of ops:  66
compiled vars:  !0 = $iban, !1 = $segments, !2 = $country, !3 = $check, !4 = $account, !5 = $digits, !6 = $first, !7 = $checksum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'strtoupper'
          2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 '+'
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $8      
          7        SEND_VAR                                                 $8
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !0, $9
    7    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAL                                                 '%2F%5E%28%5BA-Z%5D%7B2%7D%29%28%5Cd%7B2%7D%29%28%5BA-Z%5Cd%5D%7B1%2C30%7D%29%24%2F'
         12        SEND_VAR                                                 !0
         13        SEND_REF                                                 !1
         14        DO_ICALL                                         $11     
         15        BOOL_NOT                                         ~12     $11
         16      > JMPZ                                                     ~12, ->18
    8    17    > > RETURN                                                   <false>
   10    18    >   QM_ASSIGN                                        ~13     !1
         19        FETCH_LIST_R                                     $14     ~13, 1
         20        ASSIGN                                                   !2, $14
         21        FETCH_LIST_R                                     $16     ~13, 2
         22        ASSIGN                                                   !3, $16
         23        FETCH_LIST_R                                     $18     ~13, 3
         24        ASSIGN                                                   !4, $18
         25        FREE                                                     ~13
   12    26        INIT_FCALL                                               'str_split'
         27        INIT_FCALL                                               'strtr'
         28        CONCAT                                           ~20     !4, !2
         29        SEND_VAL                                                 ~20
         30        INIT_FCALL                                               'array_combine'
         31        INIT_FCALL                                               'range'
         32        SEND_VAL                                                 'A'
         33        SEND_VAL                                                 'Z'
         34        DO_ICALL                                         $21     
         35        SEND_VAR                                                 $21
         36        INIT_FCALL                                               'range'
         37        SEND_VAL                                                 10
         38        SEND_VAL                                                 35
         39        DO_ICALL                                         $22     
         40        SEND_VAR                                                 $22
         41        DO_ICALL                                         $23     
         42        SEND_VAR                                                 $23
         43        DO_ICALL                                         $24     
         44        CONCAT                                           ~25     $24, '00'
         45        SEND_VAL                                                 ~25
         46        DO_ICALL                                         $26     
         47        ASSIGN                                                   !5, $26
   13    48        INIT_FCALL                                               'array_shift'
         49        SEND_REF                                                 !5
         50        DO_ICALL                                         $28     
         51        ASSIGN                                                   !6, $28
   15    52        INIT_FCALL                                               'array_reduce'
   16    53        SEND_VAR                                                 !5
   17    54        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfDgfo%3A17%240'
   20    55        SEND_VAL                                                 ~30
   21    56        CAST                                          4  ~31     !6
         57        SEND_VAL                                                 ~31
         58        DO_ICALL                                         $32     
   15    59        ASSIGN                                                   !7, $32
   24    60        SUB                                              ~34     98, !7
         61        IS_EQUAL                                         ~35     !3, ~34
         62        VERIFY_RETURN_TYPE                                       ~35
         63      > RETURN                                                   ~35
   25    64*       VERIFY_RETURN_TYPE                                       
         65*     > RETURN                                                   null

End of function checkiban

Function %00%7Bclosure%7D%2Fin%2FfDgfo%3A17%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fDgfo
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $carry, !1 = $int
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        MUL                                              ~2      !0, 10
          3        CAST                                          4  ~3      !1
          4        ADD                                              ~4      ~2, ~3
          5        MOD                                              ~5      ~4, 97
          6        ASSIGN                                                   !0, ~5
   19     7      > RETURN                                                   !0
   20     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfDgfo%3A17%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.33 ms | 1407 KiB | 34 Q