3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($input) { switch ($input) { case $input->foo: echo 'foo'; break; case $input->bar: echo 'bar'; break; default: echo 'nah'; } } $input = new \stdObject(); $input->foo = null; $input->bar = 'huh'; test($input); $input->bar = ''; test($input); $input->bar = 0; test($input); $input->bar = null; test($input);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F5Yka
function name:  (null)
number of ops:  26
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $1      'stdObject'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   17     3        ASSIGN_OBJ                                               !0, 'foo'
          4        OP_DATA                                                  null
   18     5        ASSIGN_OBJ                                               !0, 'bar'
          6        OP_DATA                                                  'huh'
   20     7        INIT_FCALL                                               'test'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0          
   22    10        ASSIGN_OBJ                                               !0, 'bar'
         11        OP_DATA                                                  ''
   24    12        INIT_FCALL                                               'test'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0          
   26    15        ASSIGN_OBJ                                               !0, 'bar'
         16        OP_DATA                                                  0
   28    17        INIT_FCALL                                               'test'
         18        SEND_VAR                                                 !0
         19        DO_FCALL                                      0          
   30    20        ASSIGN_OBJ                                               !0, 'bar'
         21        OP_DATA                                                  null
   32    22        INIT_FCALL                                               'test'
         23        SEND_VAR                                                 !0
         24        DO_FCALL                                      0          
         25      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
filename:       /in/F5Yka
function name:  test
number of ops:  14
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        FETCH_OBJ_R                                      ~2      !0, 'foo'
          2        IS_EQUAL                                                 !0, ~2
          3      > JMPNZ                                                    ~1, ->8
    8     4    >   FETCH_OBJ_R                                      ~3      !0, 'bar'
          5        IS_EQUAL                                                 !0, ~3
          6      > JMPNZ                                                    ~1, ->10
          7    > > JMP                                                      ->12
    6     8    >   ECHO                                                     'foo'
    7     9      > JMP                                                      ->13
    9    10    >   ECHO                                                     'bar'
   10    11      > JMP                                                      ->13
   12    12    >   ECHO                                                     'nah'
   14    13    > > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.78 ms | 1403 KiB | 17 Q