3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_SESSION['person_role'] = 'admin'; // set for testing demo // Either do your switch case and set variables... $page = "default"; $role = "default"; switch($_SESSION['person_role']) { case 'admin': $page = $role = "admin"; break; case 'operator': $page = $role = "operator"; break; case 'partner': $page = $role = "partner"; break; } ?> Example W/ Switch Case.. <ul> <li class="uk-margin-left uk-margin-right"><a href="<?php echo $page; ?>.html"><?php echo ucwords($role); ?></a></li> </ul> <?php // - OR - // Just use $_SESSION data (assuming sanitized) in the HTML... $_SESSION['person_role'] = 'operator'; // set for testing demo ?> Example just using $_SESSION data.. <ul> <li class="uk-margin-left uk-margin-right"><a href="<?php echo $_SESSION['person_role']; ?>.html"><?php echo ucwords($_SESSION['person_role']); ?></a></li> </ul>
Finding entry points
Branch analysis from position: 0
5 jumps found. (Code = 188) Position 1 = 15, Position 2 = 18, Position 3 = 21, Position 4 = 24, Position 5 = 8
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 24
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
Branch analysis from position: 18
Branch analysis from position: 15
filename:       /in/iQqqn
function name:  (null)
number of ops:  49
compiled vars:  !0 = $page, !1 = $role
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   FETCH_W                      global              $2      '_SESSION'
          1        ASSIGN_DIM                                               $2, 'person_role'
          2        OP_DATA                                                  'admin'
    5     3        ASSIGN                                                   !0, 'default'
    6     4        ASSIGN                                                   !1, 'default'
    8     5        FETCH_R                      global              ~6      '_SESSION'
          6        FETCH_DIM_R                                      ~7      ~6, 'person_role'
          7      > SWITCH_STRING                                            ~7, [ 'admin':->15, 'operator':->18, 'partner':->21, ], ->24
    9     8    >   CASE                                                     ~7, 'admin'
          9      > JMPNZ                                                    ~8, ->15
   12    10    >   CASE                                                     ~7, 'operator'
         11      > JMPNZ                                                    ~8, ->18
   15    12    >   CASE                                                     ~7, 'partner'
         13      > JMPNZ                                                    ~8, ->21
         14    > > JMP                                                      ->24
   10    15    >   ASSIGN                                           ~9      !1, 'admin'
         16        ASSIGN                                                   !0, ~9
   11    17      > JMP                                                      ->24
   13    18    >   ASSIGN                                           ~11     !1, 'operator'
         19        ASSIGN                                                   !0, ~11
   14    20      > JMP                                                      ->24
   16    21    >   ASSIGN                                           ~13     !1, 'partner'
         22        ASSIGN                                                   !0, ~13
   17    23      > JMP                                                      ->24
         24    >   FREE                                                     ~7
   20    25        ECHO                                                     'Example+W%2F+Switch+Case..%0A%3Cul%3E%0A%3Cli+class%3D%22uk-margin-left+uk-margin-right%22%3E%3Ca+href%3D%22'
   22    26        ECHO                                                     !0
         27        ECHO                                                     '.html%22%3E'
         28        INIT_FCALL                                               'ucwords'
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                         $15     
         31        ECHO                                                     $15
         32        ECHO                                                     '%3C%2Fa%3E%3C%2Fli%3E%0A%3C%2Ful%3E%0A%0A'
   28    33        FETCH_W                      global              $16     '_SESSION'
         34        ASSIGN_DIM                                               $16, 'person_role'
         35        OP_DATA                                                  'operator'
   30    36        ECHO                                                     'Example+just+using+%24_SESSION+data..%0A%3Cul%3E%0A%3Cli+class%3D%22uk-margin-left+uk-margin-right%22%3E%3Ca+href%3D%22'
   32    37        FETCH_R                      global              ~18     '_SESSION'
         38        FETCH_DIM_R                                      ~19     ~18, 'person_role'
         39        ECHO                                                     ~19
         40        ECHO                                                     '.html%22%3E'
         41        INIT_FCALL                                               'ucwords'
         42        FETCH_R                      global              ~20     '_SESSION'
         43        FETCH_DIM_R                                      ~21     ~20, 'person_role'
         44        SEND_VAL                                                 ~21
         45        DO_ICALL                                         $22     
         46        ECHO                                                     $22
         47        ECHO                                                     '%3C%2Fa%3E%3C%2Fli%3E%0A%3C%2Ful%3E'
   33    48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.81 ms | 1400 KiB | 15 Q