3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public function bar() { echo 'a'; } } $foo = new Foo(); foreach ([['bar']] as $test) { $method = $test[0]; $foo->$method(); // displays "a" ==> success } foreach ([['bar']] as $test) { $foo->{$test[0]}(); // Notice "Array to string conversion" followed by // "Function name must be a string" }
based on qdBTj
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
Jump found. Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
Jump found. Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
Jump found. Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
Jump found. Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
Jump found. Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 18
Jump found. Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 11
filename:       /in/8tOim
function name:  (null)
number of ops:  20
compiled vars:  !0 = $foo, !1 = $test, !2 = $method
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
   7     1        NEW                                              $4      :-6
         2        DO_FCALL                                      0          
         3        ASSIGN                                                   !0, $4
   8     4      > FE_RESET_R                                       $7      <array>, ->11
         5    > > FE_FETCH_R                                               $7, !1, ->11
   9     6    >   FETCH_DIM_R                                      $8      !1, 0
         7        ASSIGN                                                   !2, $8
  10     8        INIT_METHOD_CALL                                         !0, !2
         9        DO_FCALL                                      0          
        10      > JMP                                                      ->5
        11    >   FE_FREE                                                  $7
  14    12      > FE_RESET_R                                       $11     <array>, ->18
        13    > > FE_FETCH_R                                               $11, !1, ->18
  15    14    >   FETCH_DIM_R                                      $12     !1, 0
        15        INIT_METHOD_CALL                                         !0, $12
        16        DO_FCALL                                      0          
        17      > JMP                                                      ->13
        18    >   FE_FREE                                                  $11
        19      > RETURN                                                   1

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/8tOim
function name:  bar
number of ops:  2
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E >   ECHO                                                     'a'
         1      > RETURN                                                   null

End of function bar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 7.3.0