3v4l.org

run code in 300+ PHP versions simultaneously
<?php $action = $_POST['action'] ?? 'default'; echo "Null coalesce with undefined variable: "; var_dump($action); if (isset($_POST['action'])) { $action = $_POST['action']; } else { $action = 'default'; } echo "If with undefined variable: "; var_dump($action); echo "\n"; // ----------------------------------------- $_POST['action'] = 'value'; $action = $_POST['action'] ?? 'default'; echo "Null coalesce with value: "; var_dump($action); $_POST['action'] = 'value'; if (isset($_POST['action'])) { $action = $_POST['action']; } else { $action = 'default'; } echo "If with value: "; var_dump($action); echo "\n"; // ----------------------------------------- $_POST['action'] = null; $action = $_POST['action'] ?? 'default'; echo "Null coalesce with explicit NULL: "; var_dump($action); // ----------------------------------------- $_POST['action'] = null; if (isset($_POST['action'])) { $action = $_POST['action']; } else { $action = 'default'; } echo "If with explicit NULL: "; var_dump($action);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 44
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 72
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 72
Branch analysis from position: 68
Branch analysis from position: 72
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 44
Branch analysis from position: 40
Branch analysis from position: 44
filename:       /in/m9KoC
function name:  (null)
number of ops:  78
compiled vars:  !0 = $action
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_IS                                         ~1      '_POST'
          1        FETCH_DIM_IS                                     ~2      ~1, 'action'
          2        COALESCE                                         ~3      ~2
          3        QM_ASSIGN                                        ~3      'default'
          4        ASSIGN                                                   !0, ~3
    5     5        ECHO                                                     'Null+coalesce+with+undefined+variable%3A+'
    6     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
    8     9        FETCH_IS                                         ~6      '_POST'
         10        ISSET_ISEMPTY_DIM_OBJ                         0          ~6, 'action'
         11      > JMPZ                                                     ~7, ->16
    9    12    >   FETCH_R                      global              ~8      '_POST'
         13        FETCH_DIM_R                                      ~9      ~8, 'action'
         14        ASSIGN                                                   !0, ~9
         15      > JMP                                                      ->17
   11    16    >   ASSIGN                                                   !0, 'default'
   14    17    >   ECHO                                                     'If+with+undefined+variable%3A++++++++++++'
   15    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
   16    21        ECHO                                                     '%0A'
   20    22        FETCH_W                      global              $13     '_POST'
         23        ASSIGN_DIM                                               $13, 'action'
         24        OP_DATA                                                  'value'
   22    25        FETCH_IS                                         ~15     '_POST'
         26        FETCH_DIM_IS                                     ~16     ~15, 'action'
         27        COALESCE                                         ~17     ~16
         28        QM_ASSIGN                                        ~17     'default'
         29        ASSIGN                                                   !0, ~17
   24    30        ECHO                                                     'Null+coalesce+with+value%3A++++++++++++++'
   25    31        INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                                 
   27    34        FETCH_W                      global              $20     '_POST'
         35        ASSIGN_DIM                                               $20, 'action'
         36        OP_DATA                                                  'value'
   29    37        FETCH_IS                                         ~22     '_POST'
         38        ISSET_ISEMPTY_DIM_OBJ                         0          ~22, 'action'
         39      > JMPZ                                                     ~23, ->44
   30    40    >   FETCH_R                      global              ~24     '_POST'
         41        FETCH_DIM_R                                      ~25     ~24, 'action'
         42        ASSIGN                                                   !0, ~25
         43      > JMP                                                      ->45
   32    44    >   ASSIGN                                                   !0, 'default'
   35    45    >   ECHO                                                     'If+with+value%3A+++++++++++++++++++++++++'
   36    46        INIT_FCALL                                               'var_dump'
         47        SEND_VAR                                                 !0
         48        DO_ICALL                                                 
   37    49        ECHO                                                     '%0A'
   41    50        FETCH_W                      global              $29     '_POST'
         51        ASSIGN_DIM                                               $29, 'action'
         52        OP_DATA                                                  null
   43    53        FETCH_IS                                         ~31     '_POST'
         54        FETCH_DIM_IS                                     ~32     ~31, 'action'
         55        COALESCE                                         ~33     ~32
         56        QM_ASSIGN                                        ~33     'default'
         57        ASSIGN                                                   !0, ~33
   45    58        ECHO                                                     'Null+coalesce+with+explicit+NULL%3A++++++'
   46    59        INIT_FCALL                                               'var_dump'
         60        SEND_VAR                                                 !0
         61        DO_ICALL                                                 
   50    62        FETCH_W                      global              $36     '_POST'
         63        ASSIGN_DIM                                               $36, 'action'
         64        OP_DATA                                                  null
   52    65        FETCH_IS                                         ~38     '_POST'
         66        ISSET_ISEMPTY_DIM_OBJ                         0          ~38, 'action'
         67      > JMPZ                                                     ~39, ->72
   53    68    >   FETCH_R                      global              ~40     '_POST'
         69        FETCH_DIM_R                                      ~41     ~40, 'action'
         70        ASSIGN                                                   !0, ~41
         71      > JMP                                                      ->73
   55    72    >   ASSIGN                                                   !0, 'default'
   58    73    >   ECHO                                                     'If+with+explicit+NULL%3A+++++++++++++++++'
   59    74        INIT_FCALL                                               'var_dump'
         75        SEND_VAR                                                 !0
         76        DO_ICALL                                                 
         77      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.4 ms | 1400 KiB | 15 Q