3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculate($input) { $count = 0; foreach ($input as $value) if (!empty($value)) $count++; return $count < 3 ? $count * 8.5 : 20; } // VOORBEELD 1: $_SESSION = array(); // simuleren van een SESSION array $_SESSION['input']['1'] = 'JA'; $_SESSION['input']['2'] = ''; $_SESSION['input']['3'] = 'JA'; $_SESSION['input']['4'] = ''; $_SESSION['input']['5'] = ''; $_SESSION['input']['6'] = ''; echo 'Voorbeeld 1: het bedrag is: ' . number_format(calculate($_SESSION['input']), 2, ',', '.') . ' euro.' . PHP_EOL; // VOORBEELD 2: $_SESSION = array(); // simuleren van een SESSION array $_SESSION['input']['1'] = 'NEE'; $_SESSION['input']['2'] = ''; $_SESSION['input']['3'] = 'JA'; $_SESSION['input']['4'] = 'JA'; $_SESSION['input']['5'] = 'NEE'; $_SESSION['input']['6'] = ''; echo 'Voorbeeld 1: het bedrag is: ' . number_format(calculate($_SESSION['input']), 2, ',', '.') . ' euro.'; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nTij9
function name:  (null)
number of ops:  82
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_W                      global              $0      '_SESSION'
          1        ASSIGN                                                   $0, <array>
   11     2        FETCH_W                      global              $2      '_SESSION'
          3        FETCH_DIM_W                                      $3      $2, 'input'
          4        ASSIGN_DIM                                               $3, 1
          5        OP_DATA                                                  'JA'
   12     6        FETCH_W                      global              $5      '_SESSION'
          7        FETCH_DIM_W                                      $6      $5, 'input'
          8        ASSIGN_DIM                                               $6, 2
          9        OP_DATA                                                  ''
   13    10        FETCH_W                      global              $8      '_SESSION'
         11        FETCH_DIM_W                                      $9      $8, 'input'
         12        ASSIGN_DIM                                               $9, 3
         13        OP_DATA                                                  'JA'
   14    14        FETCH_W                      global              $11     '_SESSION'
         15        FETCH_DIM_W                                      $12     $11, 'input'
         16        ASSIGN_DIM                                               $12, 4
         17        OP_DATA                                                  ''
   15    18        FETCH_W                      global              $14     '_SESSION'
         19        FETCH_DIM_W                                      $15     $14, 'input'
         20        ASSIGN_DIM                                               $15, 5
         21        OP_DATA                                                  ''
   16    22        FETCH_W                      global              $17     '_SESSION'
         23        FETCH_DIM_W                                      $18     $17, 'input'
         24        ASSIGN_DIM                                               $18, 6
         25        OP_DATA                                                  ''
   18    26        INIT_FCALL                                               'number_format'
         27        INIT_FCALL                                               'calculate'
         28        FETCH_R                      global              ~20     '_SESSION'
         29        FETCH_DIM_R                                      ~21     ~20, 'input'
         30        SEND_VAL                                                 ~21
         31        DO_FCALL                                      0  $22     
         32        SEND_VAR                                                 $22
         33        SEND_VAL                                                 2
         34        SEND_VAL                                                 '%2C'
         35        SEND_VAL                                                 '.'
         36        DO_ICALL                                         $23     
         37        CONCAT                                           ~24     'Voorbeeld+1%3A+het+bedrag+is%3A+', $23
         38        CONCAT                                           ~25     ~24, '+euro.'
         39        CONCAT                                           ~26     ~25, '%0A'
         40        ECHO                                                     ~26
   22    41        FETCH_W                      global              $27     '_SESSION'
         42        ASSIGN                                                   $27, <array>
   23    43        FETCH_W                      global              $29     '_SESSION'
         44        FETCH_DIM_W                                      $30     $29, 'input'
         45        ASSIGN_DIM                                               $30, 1
         46        OP_DATA                                                  'NEE'
   24    47        FETCH_W                      global              $32     '_SESSION'
         48        FETCH_DIM_W                                      $33     $32, 'input'
         49        ASSIGN_DIM                                               $33, 2
         50        OP_DATA                                                  ''
   25    51        FETCH_W                      global              $35     '_SESSION'
         52        FETCH_DIM_W                                      $36     $35, 'input'
         53        ASSIGN_DIM                                               $36, 3
         54        OP_DATA                                                  'JA'
   26    55        FETCH_W                      global              $38     '_SESSION'
         56        FETCH_DIM_W                                      $39     $38, 'input'
         57        ASSIGN_DIM                                               $39, 4
         58        OP_DATA                                                  'JA'
   27    59        FETCH_W                      global              $41     '_SESSION'
         60        FETCH_DIM_W                                      $42     $41, 'input'
         61        ASSIGN_DIM                                               $42, 5
         62        OP_DATA                                                  'NEE'
   28    63        FETCH_W                      global              $44     '_SESSION'
         64        FETCH_DIM_W                                      $45     $44, 'input'
         65        ASSIGN_DIM                                               $45, 6
         66        OP_DATA                                                  ''
   30    67        INIT_FCALL                                               'number_format'
         68        INIT_FCALL                                               'calculate'
         69        FETCH_R                      global              ~47     '_SESSION'
         70        FETCH_DIM_R                                      ~48     ~47, 'input'
         71        SEND_VAL                                                 ~48
         72        DO_FCALL                                      0  $49     
         73        SEND_VAR                                                 $49
         74        SEND_VAL                                                 2
         75        SEND_VAL                                                 '%2C'
         76        SEND_VAL                                                 '.'
         77        DO_ICALL                                         $50     
         78        CONCAT                                           ~51     'Voorbeeld+1%3A+het+bedrag+is%3A+', $50
         79        CONCAT                                           ~52     ~51, '+euro.'
         80        ECHO                                                     ~52
   32    81      > RETURN                                                   1

Function calculate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/nTij9
function name:  calculate
number of ops:  18
compiled vars:  !0 = $input, !1 = $count, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, 0
    4     2      > FE_RESET_R                                       $4      !0, ->9
          3    > > FE_FETCH_R                                               $4, !2, ->9
          4    >   ISSET_ISEMPTY_CV                                 ~5      !2
          5        BOOL_NOT                                         ~6      ~5
          6      > JMPZ                                                     ~6, ->8
          7    >   PRE_INC                                                  !1
          8    > > JMP                                                      ->3
          9    >   FE_FREE                                                  $4
    5    10        IS_SMALLER                                               !1, 3
         11      > JMPZ                                                     ~8, ->15
         12    >   MUL                                              ~9      !1, 8.5
         13        QM_ASSIGN                                        ~10     ~9
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~10     20
         16    > > RETURN                                                   ~10
    6    17*     > RETURN                                                   null

End of function calculate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.19 ms | 1407 KiB | 17 Q