3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_switch($value) { $matches = ""; switch ($value) { case 0: $matches .= "0 "; } switch ($value) { case 1: $matches .= "1 "; } switch ($value) { case true: $matches .= "true "; } switch ($value) { case false: $matches .= "false "; } switch ($value) { case null: $matches .= "null "; } switch ($value) { case "0": $matches .= "'0' "; } switch ($value) { case "1": $matches .= "'1' "; } return $matches; } foreach (array(0, 1, true, false, null, "0", "1") as $value) { $matches = test_switch($value); var_dump(array('value' => $value, 'matches' => trim($matches))); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 15
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 15
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/hksGU
function name:  (null)
number of ops:  17
compiled vars:  !0 = $value, !1 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E > > FE_RESET_R                                       $2      <array>, ->15
          1    > > FE_FETCH_R                                               $2, !0, ->15
   37     2    >   INIT_FCALL                                               'test_switch'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   38     6        INIT_FCALL                                               'var_dump'
          7        INIT_ARRAY                                       ~5      !0, 'value'
          8        INIT_FCALL                                               'trim'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11        ADD_ARRAY_ELEMENT                                ~5      $6, 'matches'
         12        SEND_VAL                                                 ~5
         13        DO_ICALL                                                 
   36    14      > JMP                                                      ->1
         15    >   FE_FREE                                                  $2
   39    16      > RETURN                                                   1

Function test_switch:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
Branch analysis from position: 29
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
Branch analysis from position: 25
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
Branch analysis from position: 21
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
Branch analysis from position: 17
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
Branch analysis from position: 13
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
Branch analysis from position: 9
filename:       /in/hksGU
function name:  test_switch
number of ops:  32
compiled vars:  !0 = $value, !1 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, ''
    6     2        IS_EQUAL                                                 !0, 0
          3      > JMPNZ                                                    ~3, ->5
          4    > > JMP                                                      ->6
    7     5    >   ASSIGN_OP                                     8          !1, '0+'
   10     6    >   IS_EQUAL                                                 !0, 1
          7      > JMPNZ                                                    ~5, ->9
          8    > > JMP                                                      ->10
   11     9    >   ASSIGN_OP                                     8          !1, '1+'
   13    10    >   IS_EQUAL                                                 !0, <true>
         11      > JMPNZ                                                    ~7, ->13
         12    > > JMP                                                      ->14
   15    13    >   ASSIGN_OP                                     8          !1, 'true+'
   17    14    >   IS_EQUAL                                                 !0, <false>
         15      > JMPNZ                                                    ~9, ->17
         16    > > JMP                                                      ->18
   19    17    >   ASSIGN_OP                                     8          !1, 'false+'
   21    18    >   IS_EQUAL                                                 !0, null
         19      > JMPNZ                                                    ~11, ->21
         20    > > JMP                                                      ->22
   23    21    >   ASSIGN_OP                                     8          !1, 'null+'
   26    22    >   IS_EQUAL                                                 !0, '0'
         23      > JMPNZ                                                    ~13, ->25
         24    > > JMP                                                      ->26
   27    25    >   ASSIGN_OP                                     8          !1, '%270%27+'
   30    26    >   IS_EQUAL                                                 !0, '1'
         27      > JMPNZ                                                    ~15, ->29
         28    > > JMP                                                      ->30
   31    29    >   ASSIGN_OP                                     8          !1, '%271%27+'
   33    30    > > RETURN                                                   !1
   34    31*     > RETURN                                                   null

End of function test_switch

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.83 ms | 1394 KiB | 18 Q