3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { function f() { return 'I am foo'; } } class Bar { function f() { return 'I am bar'; } } if ( mt_rand(0,1) == 0 ) { $classname = 'Foo'; } else { $classname = 'Bar'; } $obj = new $classname(); echo $obj->f();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AD2m3
function name:  (null)
number of ops:  17
compiled vars:  !0 = $classname, !1 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'mt_rand'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 1
          3        DO_ICALL                                         $2      
          4        IS_EQUAL                                                 $2, 0
          5      > JMPZ                                                     ~3, ->8
   15     6    >   ASSIGN                                                   !0, 'Foo'
   14     7      > JMP                                                      ->9
   18     8    >   ASSIGN                                                   !0, 'Bar'
   21     9    >   FETCH_CLASS                                   0  $6      !0
         10        NEW                                              $7      $6
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $7
   23    13        INIT_METHOD_CALL                                         !1, 'f'
         14        DO_FCALL                                      0  $10     
         15        ECHO                                                     $10
         16      > RETURN                                                   1

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

End of function f

End of class Foo.

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

End of function f

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.01 ms | 1068 KiB | 14 Q