3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Car { abstract function objectify(); } class BMW extends Car { public function objectify() { return "I'm a BMW"; } } class Honda extends Car { public function objectify() { return "I'm a Honda"; } } class Tesla extends Car { public function objectify() { return "I'm a Tesla"; } } $carTypes = array("Germany" => "BMW", "Japan" => "Honda", "America" => "Tesla"); $country = "Germany"; //replace this with actual user input, in your version $car = new $carTypes[$country](); echo $car->objectify();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0WSLO
function name:  (null)
number of ops:  11
compiled vars:  !0 = $carTypes, !1 = $country, !2 = $car
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ASSIGN                                                   !0, <array>
   34     1        ASSIGN                                                   !1, 'Germany'
   36     2        FETCH_DIM_R                                      ~5      !0, !1
          3        FETCH_CLASS                                   0  $6      ~5
          4        NEW                                              $7      $6
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $7
   37     7        INIT_METHOD_CALL                                         !2, 'objectify'
          8        DO_FCALL                                      0  $10     
          9        ECHO                                                     $10
         10      > RETURN                                                   1

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

End of function objectify

End of class Car.

Class BMW:
Function objectify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0WSLO
function name:  objectify
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   'I%27m+a+BMW'
   13     1*     > RETURN                                                   null

End of function objectify

End of class BMW.

Class Honda:
Function objectify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0WSLO
function name:  objectify
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E > > RETURN                                                   'I%27m+a+Honda'
   21     1*     > RETURN                                                   null

End of function objectify

End of class Honda.

Class Tesla:
Function objectify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0WSLO
function name:  objectify
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E > > RETURN                                                   'I%27m+a+Tesla'
   29     1*     > RETURN                                                   null

End of function objectify

End of class Tesla.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
251.07 ms | 1003 KiB | 14 Q