3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('FIELDS', ['name', 'address', 'city']); define( 'HTML_FIELD_FORM', <<<'HTML' <h2>%1$s</h2> <form method="post" autocomplete="off"> <input type="text" name="%1$s" autocomplete="off" placeholder="%1$s"><br> <input value="submit" type="submit"> </form> HTML ); define( 'HTML_CLEAR_FORM', <<<'HTML' <form method="post" autocomplete="off"> <input type="text" name="%1$s" value="1" hidden><br> <input value="%1$s" type="submit"> </form> HTML ); foreach (FIELDS as $field) { if (isset($_POST[$field])) { // Set session & cookie from post $_SESSION[$field] = $_POST[$field]; setcookie($field, $_POST[$field]); } elseif (isset($_COOKIE[$field])) { // Set session from cookie $_SESSION[$field] = $_COOKIE[$field]; } elseif (!isset($_SESSION[$field])) { // Present individual field form printf(HTML_FIELD_FORM, $field); } } foreach (['clear_session', 'clear_cookies'] as $action) { printf(HTML_CLEAR_FORM, $action); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 49
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 49
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 30
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 39
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 48
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 48
Branch analysis from position: 49
2 jumps found. (Code = 77) Position 1 = 51, Position 2 = 58
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 58
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 49
filename:       /in/GAp5oX
function name:  (null)
number of ops:  60
compiled vars:  !0 = $field, !1 = $action
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'FIELDS'
          2        SEND_VAL                                                 <array>
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'define'
    5     5        SEND_VAL                                                 'HTML_FIELD_FORM'
    7     6        SEND_VAL                                                 '%3Ch2%3E%251%24s%3C%2Fh2%3E%0A%3Cform+method%3D%22post%22+autocomplete%3D%22off%22%3E%0A++++%3Cinput+type%3D%22text%22+name%3D%22%251%24s%22+autocomplete%3D%22off%22+placeholder%3D%22%251%24s%22%3E%3Cbr%3E%0A++++%3Cinput+value%3D%22submit%22+type%3D%22submit%22%3E%0A%3C%2Fform%3E'
          7        DO_ICALL                                                 
   14     8        INIT_FCALL                                               'define'
   15     9        SEND_VAL                                                 'HTML_CLEAR_FORM'
   17    10        SEND_VAL                                                 '%3Cform+method%3D%22post%22+autocomplete%3D%22off%22%3E%0A++++%3Cinput+type%3D%22text%22+name%3D%22%251%24s%22+value%3D%221%22+hidden%3E%3Cbr%3E%0A++++%3Cinput+value%3D%22%251%24s%22+type%3D%22submit%22%3E%0A%3C%2Fform%3E'
         11        DO_ICALL                                                 
   24    12        FETCH_CONSTANT                                   ~5      'FIELDS'
         13      > FE_RESET_R                                       $6      ~5, ->49
         14    > > FE_FETCH_R                                               $6, !0, ->49
   25    15    >   FETCH_IS                                         ~7      '_POST'
         16        ISSET_ISEMPTY_DIM_OBJ                         0          ~7, !0
         17      > JMPZ                                                     ~8, ->30
   27    18    >   FETCH_R                      global              ~11     '_POST'
         19        FETCH_DIM_R                                      ~12     ~11, !0
         20        FETCH_W                      global              $9      '_SESSION'
         21        ASSIGN_DIM                                               $9, !0
         22        OP_DATA                                                  ~12
   28    23        INIT_FCALL                                               'setcookie'
         24        SEND_VAR                                                 !0
         25        FETCH_R                      global              ~13     '_POST'
         26        FETCH_DIM_R                                      ~14     ~13, !0
         27        SEND_VAL                                                 ~14
         28        DO_ICALL                                                 
         29      > JMP                                                      ->48
   29    30    >   FETCH_IS                                         ~16     '_COOKIE'
         31        ISSET_ISEMPTY_DIM_OBJ                         0          ~16, !0
         32      > JMPZ                                                     ~17, ->39
   31    33    >   FETCH_R                      global              ~20     '_COOKIE'
         34        FETCH_DIM_R                                      ~21     ~20, !0
         35        FETCH_W                      global              $18     '_SESSION'
         36        ASSIGN_DIM                                               $18, !0
         37        OP_DATA                                                  ~21
         38      > JMP                                                      ->48
   32    39    >   FETCH_IS                                         ~22     '_SESSION'
         40        ISSET_ISEMPTY_DIM_OBJ                         0  ~23     ~22, !0
         41        BOOL_NOT                                         ~24     ~23
         42      > JMPZ                                                     ~24, ->48
   34    43    >   INIT_FCALL                                               'printf'
         44        FETCH_CONSTANT                                   ~25     'HTML_FIELD_FORM'
         45        SEND_VAL                                                 ~25
         46        SEND_VAR                                                 !0
         47        DO_ICALL                                                 
   24    48    > > JMP                                                      ->14
         49    >   FE_FREE                                                  $6
   38    50      > FE_RESET_R                                       $27     <array>, ->58
         51    > > FE_FETCH_R                                               $27, !1, ->58
   39    52    >   INIT_FCALL                                               'printf'
         53        FETCH_CONSTANT                                   ~28     'HTML_CLEAR_FORM'
         54        SEND_VAL                                                 ~28
         55        SEND_VAR                                                 !1
         56        DO_ICALL                                                 
   38    57      > JMP                                                      ->51
         58    >   FE_FREE                                                  $27
   40    59      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.37 ms | 1400 KiB | 19 Q