3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function getFoo() { return "FOO!"; } } class Bar { protected function getClass() { return 'Foo'; } } $a = new Bar(); $b = new ${$a->getClass()}; var_dump($b->getFoo());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gET5I
function name:  (null)
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $2      'Bar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   17     3        INIT_METHOD_CALL                                         !0, 'getClass'
          4        DO_FCALL                                      0  $5      
          5        FETCH_R                      local               ~6      $5
          6        FETCH_CLASS                                   0  $7      ~6
          7        NEW                                              $8      $7
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $8
   19    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !1, 'getFoo'
         12        DO_FCALL                                      0  $11     
         13        SEND_VAR                                                 $11
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Class Foo:
Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gET5I
function name:  getFoo
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   'FOO%21'
    6     1*     > RETURN                                                   null

End of function getfoo

End of class Foo.

Class Bar:
Function getclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gET5I
function name:  getClass
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E > > RETURN                                                   'Foo'
   12     1*     > RETURN                                                   null

End of function getclass

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.75 ms | 1395 KiB | 15 Q