3v4l.org

run code in 300+ PHP versions simultaneously
<?php const ENUM_RED = 1; const ENUM_BLUE = 2; const ENUM_GREEN = 4; function doSwitch($option) { switch ($option) { case ENUM_RED: return 'red'; case ENUM_BLUE: return 'blue'; case ENUM_GREEN: return 'green'; case ENUM_GREEN | ENUM_RED: return 'brown'; case ENUM_BLUE | ENUM_GREEN: return 'seagreen'; } } echo doSwitch(ENUM_RED | ENUM_GREEN);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BdhAG
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CONST                                            'ENUM_RED', 1
    3     1        DECLARE_CONST                                            'ENUM_BLUE', 2
    4     2        DECLARE_CONST                                            'ENUM_GREEN', 4
   24     3        INIT_FCALL                                               'doswitch'
          4        FETCH_CONSTANT                                   ~0      'ENUM_RED'
          5        FETCH_CONSTANT                                   ~1      'ENUM_GREEN'
          6        BW_OR                                            ~2      ~0, ~1
          7        SEND_VAL                                                 ~2
          8        DO_FCALL                                      0  $3      
          9        ECHO                                                     $3
         10      > RETURN                                                   1

Function doswitch:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 22
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BdhAG
function name:  doSwitch
number of ops:  27
compiled vars:  !0 = $option
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        FETCH_CONSTANT                                   ~2      'ENUM_RED'
          2        IS_EQUAL                                                 !0, ~2
          3      > JMPNZ                                                    ~1, ->21
   11     4    >   FETCH_CONSTANT                                   ~3      'ENUM_BLUE'
          5        IS_EQUAL                                                 !0, ~3
          6      > JMPNZ                                                    ~1, ->22
   13     7    >   FETCH_CONSTANT                                   ~4      'ENUM_GREEN'
          8        IS_EQUAL                                                 !0, ~4
          9      > JMPNZ                                                    ~1, ->23
   16    10    >   FETCH_CONSTANT                                   ~5      'ENUM_GREEN'
         11        FETCH_CONSTANT                                   ~6      'ENUM_RED'
         12        BW_OR                                            ~7      ~5, ~6
         13        IS_EQUAL                                                 !0, ~7
         14      > JMPNZ                                                    ~1, ->24
   18    15    >   FETCH_CONSTANT                                   ~8      'ENUM_BLUE'
         16        FETCH_CONSTANT                                   ~9      'ENUM_GREEN'
         17        BW_OR                                            ~10     ~8, ~9
         18        IS_EQUAL                                                 !0, ~10
         19      > JMPNZ                                                    ~1, ->25
         20    > > JMP                                                      ->26
   10    21    > > RETURN                                                   'red'
   12    22    > > RETURN                                                   'blue'
   14    23    > > RETURN                                                   'green'
   17    24    > > RETURN                                                   'brown'
   19    25    > > RETURN                                                   'seagreen'
   22    26    > > RETURN                                                   null

End of function doswitch

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.81 ms | 1403 KiB | 14 Q