3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function doSomething(array $a) { $data = array(); if (array_key_exists('a', $a)) { $data[] = 'Hello ' . $a['a']; } if (array_key_exists('b', $a)) { $data[] = ' ' . $a['b']; } if (array_key_exists('c', $a)) { $data[] = $a['c']; } if (array_key_exists('d', $a)) { $data[] = 'bar'.$a['d']; } if (array_key_exists('f', $a)) { $data[] = ' tue' . $a['f']; } return $data; } public function DoSameThing(array $a) { $data = array(); foreach ($a as $k => $v) { switch ($k) { case 'a': $data[] = 'Hello ' . $v; break; case 'b': $data[] = ' ' . $v; break; case 'c': $data[] = $v; break; case 'd': $data[] = 'bar' . $v; break; case 'f': $data[] = ' tue' . $v; break; } } return $data; } } $foo = new Foo; echo implode( ' ', $foo->doSomething( array( 'a' => 'John', 'b' => 'is happy', 'c' => ' and ', 'd' => 'bie', 'e' => 'Hello world', 'f' => ' rick', ) ) ); echo "\n"; echo implode( ' ', $foo->doSamething( array( 'a' => 'John', 'b' => 'is happy', 'c' => ' and ', 'd' => 'bie', 'e' => 'Hello world', 'f' => ' rick', ) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JFIoV
function name:  (null)
number of ops:  21
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   54     3        INIT_FCALL                                               'implode'
   55     4        SEND_VAL                                                 '+'
   56     5        INIT_METHOD_CALL                                         !0, 'doSomething'
   58     6        SEND_VAL_EX                                              <array>
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                         $5      
         10        ECHO                                                     $5
   67    11        ECHO                                                     '%0A'
   68    12        INIT_FCALL                                               'implode'
   69    13        SEND_VAL                                                 '+'
   70    14        INIT_METHOD_CALL                                         !0, 'doSamething'
   72    15        SEND_VAL_EX                                              <array>
         16        DO_FCALL                                      0  $6      
         17        SEND_VAR                                                 $6
         18        DO_ICALL                                         $7      
         19        ECHO                                                     $7
   80    20      > RETURN                                                   1

Class Foo:
Function dosomething:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 25
Branch analysis from position: 19
Branch analysis from position: 14
Branch analysis from position: 8
filename:       /in/JFIoV
function name:  doSomething
number of ops:  33
compiled vars:  !0 = $a, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        ASSIGN                                                   !1, <array>
    7     2        ARRAY_KEY_EXISTS                                         'a', !0
          3      > JMPZ                                                     ~3, ->8
    8     4    >   FETCH_DIM_R                                      ~5      !0, 'a'
          5        CONCAT                                           ~6      'Hello+', ~5
          6        ASSIGN_DIM                                               !1
          7        OP_DATA                                                  ~6
   10     8    >   ARRAY_KEY_EXISTS                                         'b', !0
          9      > JMPZ                                                     ~7, ->14
   11    10    >   FETCH_DIM_R                                      ~9      !0, 'b'
         11        CONCAT                                           ~10     '+', ~9
         12        ASSIGN_DIM                                               !1
         13        OP_DATA                                                  ~10
   13    14    >   ARRAY_KEY_EXISTS                                         'c', !0
         15      > JMPZ                                                     ~11, ->19
   14    16    >   FETCH_DIM_R                                      ~13     !0, 'c'
         17        ASSIGN_DIM                                               !1
         18        OP_DATA                                                  ~13
   16    19    >   ARRAY_KEY_EXISTS                                         'd', !0
         20      > JMPZ                                                     ~14, ->25
   17    21    >   FETCH_DIM_R                                      ~16     !0, 'd'
         22        CONCAT                                           ~17     'bar', ~16
         23        ASSIGN_DIM                                               !1
         24        OP_DATA                                                  ~17
   19    25    >   ARRAY_KEY_EXISTS                                         'f', !0
         26      > JMPZ                                                     ~18, ->31
   20    27    >   FETCH_DIM_R                                      ~20     !0, 'f'
         28        CONCAT                                           ~21     '+tue', ~20
         29        ASSIGN_DIM                                               !1
         30        OP_DATA                                                  ~21
   23    31    > > RETURN                                                   !1
   24    32*     > RETURN                                                   null

End of function dosomething

Function dosamething:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 37
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 37
Branch analysis from position: 4
7 jumps found. (Code = 188) Position 1 = 17, Position 2 = 21, Position 3 = 25, Position 4 = 28, Position 5 = 32, Position 6 = 36, Position 7 = 6
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 36
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 21
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 28
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 32
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 32
Branch analysis from position: 28
Branch analysis from position: 25
Branch analysis from position: 21
Branch analysis from position: 17
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/JFIoV
function name:  DoSameThing
number of ops:  40
compiled vars:  !0 = $a, !1 = $data, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   28     1        ASSIGN                                                   !1, <array>
   29     2      > FE_RESET_R                                       $5      !0, ->37
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->37
          4    >   ASSIGN                                                   !3, ~6
   30     5      > SWITCH_STRING                                            !3, [ 'a':->17, 'b':->21, 'c':->25, 'd':->28, 'f':->32, ], ->36
   31     6    >   IS_EQUAL                                                 !3, 'a'
          7      > JMPNZ                                                    ~8, ->17
   34     8    >   IS_EQUAL                                                 !3, 'b'
          9      > JMPNZ                                                    ~8, ->21
   37    10    >   IS_EQUAL                                                 !3, 'c'
         11      > JMPNZ                                                    ~8, ->25
   40    12    >   IS_EQUAL                                                 !3, 'd'
         13      > JMPNZ                                                    ~8, ->28
   43    14    >   IS_EQUAL                                                 !3, 'f'
         15      > JMPNZ                                                    ~8, ->32
         16    > > JMP                                                      ->36
   32    17    >   CONCAT                                           ~10     'Hello+', !2
         18        ASSIGN_DIM                                               !1
         19        OP_DATA                                                  ~10
   33    20      > JMP                                                      ->36
   35    21    >   CONCAT                                           ~12     '+', !2
         22        ASSIGN_DIM                                               !1
         23        OP_DATA                                                  ~12
   36    24      > JMP                                                      ->36
   38    25    >   ASSIGN_DIM                                               !1
         26        OP_DATA                                                  !2
   39    27      > JMP                                                      ->36
   41    28    >   CONCAT                                           ~15     'bar', !2
         29        ASSIGN_DIM                                               !1
         30        OP_DATA                                                  ~15
   42    31      > JMP                                                      ->36
   44    32    >   CONCAT                                           ~17     '+tue', !2
         33        ASSIGN_DIM                                               !1
         34        OP_DATA                                                  ~17
   45    35      > JMP                                                      ->36
   29    36    > > JMP                                                      ->3
         37    >   FE_FREE                                                  $5
   49    38      > RETURN                                                   !1
   50    39*     > RETURN                                                   null

End of function dosamething

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.68 ms | 1404 KiB | 15 Q