3v4l.org

run code in 300+ PHP versions simultaneously
<?php Class Vehicle{ /* Delcaration of private variables */ private $_name = "Default Vehicle"; private $_model; private $_type; private $_identification; /* Declaration of private arrays */ private $_mode = array(); private $feature = array(); /* Magic code entry function, think of it as a main() in C/C++ */ public function __construct( $name, $model, $type ){ $this->create_vehicle( $name, $model, $type ); } /* __getter function */ public function __get( $variable ){ if( !empty($this->$variable) ){ $get_variable = $this->$variable; } return $get_variable; } /* __setter function */ public function __set( $variable, $target ){ $this->$variable = $target; } /* Private function */ private function create_vehicle( $name, $model, $type ){ $this->__set( "_name", $name ); $this->__set( "_model", $model); $this->__set( "_type", $type ); } } //end of the class. ?> <?php /* Using the Vehicle class to create a vehicle by passing three parameters 'vehicle name', 'vehicle model', 'vehicle type' to the class. */ $toyota = new Vehicle("Toyotal 101", "TY101", "Sedan"); /* Get the name and store it in a variable for later use */ $vehicle_name = $toyota->__get('_name'); /* Set the vehicle mode or status */ $vehicle_mode = array( 'gas' => 50, 'ignition' => 'OFF', 'tire' => "OK", 'year' => 2020, 'mfg' => 'Toyoda', 'condition' => 'New' ); /* Create vehicle features */ $vehicle_feature = array( "Tire" => 4, "Horse Power" => "V6", "blah blah" => "foo", "Airbag" => 2, "Transmission" => "Automatic" //.... ); /* Create vehicle identification */ $vehicle_identification = array( "VIN" => "0001234567ABCD89", "NAME" => $vehicle_name, "FEATURE" => $vehicle_feature, "MODEL" => $vehicle_mode, "YEAR" => 2020, "MFG" => "Totota" ); /* Set vehicle identification */ $toyota->__set("_identification", $vehicle_identification ); /* Set vehicle features */ $toyota->__set("_feature", $vehicle_feature ); /* Set vehicle mode */ $toyota->__set("_mode", $vehicle_mode); /* Retrieve information and store them in variable using __get (getter) */ $vehicle_name = $toyota->__get('_name'); $vehicle_mode = $toyota->__get('_mode'); $vehicle_id = $toyota->__get('_identification'); $vehicle_features = $toyota->__get('_feature'); $vehicle_type = $toyota->__get('_type'); $vehicle_model = $toyota->__get('_model'); /* Printing information using store values in the variables. */ echo "Printing Vehicle Information\n"; echo "*****************************\n"; echo "Vehicle name is $vehicle_name \n"; echo "Vehicle Model is $vehicle_model \n"; echo "Vehich type is $vehicle_type \n"; printf("\n\n"); echo "Printing Vehicle Mode\n"; echo "***********************\n"; print_r( $vehicle_mode ); printf("\n\n"); echo "Printing Vehicle Features\n"; echo "**************************\n"; print_r( $vehicle_features ); printf("\n\n"); echo "Printing Vehicle Identification\n"; echo "******************************\n"; print_r( $vehicle_id ); printf("\n\n"); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TkGZg
function name:  (null)
number of ops:  98
compiled vars:  !0 = $toyota, !1 = $vehicle_name, !2 = $vehicle_mode, !3 = $vehicle_feature, !4 = $vehicle_identification, !5 = $vehicle_id, !6 = $vehicle_features, !7 = $vehicle_type, !8 = $vehicle_model
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   ECHO                                                     '%0A'
   54     1        NEW                                              $9      'Vehicle'
          2        SEND_VAL_EX                                              'Toyotal+101'
          3        SEND_VAL_EX                                              'TY101'
          4        SEND_VAL_EX                                              'Sedan'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $9
   57     7        INIT_METHOD_CALL                                         !0, '__get'
          8        SEND_VAL_EX                                              '_name'
          9        DO_FCALL                                      0  $12     
         10        ASSIGN                                                   !1, $12
   60    11        ASSIGN                                                   !2, <array>
   70    12        ASSIGN                                                   !3, <array>
   81    13        INIT_ARRAY                                       ~16     '0001234567ABCD89', 'VIN'
   82    14        ADD_ARRAY_ELEMENT                                ~16     !1, 'NAME'
   83    15        ADD_ARRAY_ELEMENT                                ~16     !3, 'FEATURE'
   84    16        ADD_ARRAY_ELEMENT                                ~16     !2, 'MODEL'
   85    17        ADD_ARRAY_ELEMENT                                ~16     2020, 'YEAR'
   86    18        ADD_ARRAY_ELEMENT                                ~16     'Totota', 'MFG'
   80    19        ASSIGN                                                   !4, ~16
   91    20        INIT_METHOD_CALL                                         !0, '__set'
         21        SEND_VAL_EX                                              '_identification'
         22        SEND_VAR_EX                                              !4
         23        DO_FCALL                                      0          
   94    24        INIT_METHOD_CALL                                         !0, '__set'
         25        SEND_VAL_EX                                              '_feature'
         26        SEND_VAR_EX                                              !3
         27        DO_FCALL                                      0          
   97    28        INIT_METHOD_CALL                                         !0, '__set'
         29        SEND_VAL_EX                                              '_mode'
         30        SEND_VAR_EX                                              !2
         31        DO_FCALL                                      0          
  100    32        INIT_METHOD_CALL                                         !0, '__get'
         33        SEND_VAL_EX                                              '_name'
         34        DO_FCALL                                      0  $21     
         35        ASSIGN                                                   !1, $21
  101    36        INIT_METHOD_CALL                                         !0, '__get'
         37        SEND_VAL_EX                                              '_mode'
         38        DO_FCALL                                      0  $23     
         39        ASSIGN                                                   !2, $23
  102    40        INIT_METHOD_CALL                                         !0, '__get'
         41        SEND_VAL_EX                                              '_identification'
         42        DO_FCALL                                      0  $25     
         43        ASSIGN                                                   !5, $25
  103    44        INIT_METHOD_CALL                                         !0, '__get'
         45        SEND_VAL_EX                                              '_feature'
         46        DO_FCALL                                      0  $27     
         47        ASSIGN                                                   !6, $27
  104    48        INIT_METHOD_CALL                                         !0, '__get'
         49        SEND_VAL_EX                                              '_type'
         50        DO_FCALL                                      0  $29     
         51        ASSIGN                                                   !7, $29
  105    52        INIT_METHOD_CALL                                         !0, '__get'
         53        SEND_VAL_EX                                              '_model'
         54        DO_FCALL                                      0  $31     
         55        ASSIGN                                                   !8, $31
  109    56        ECHO                                                     'Printing+Vehicle+Information%0A'
  110    57        ECHO                                                     '%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0A'
  112    58        ROPE_INIT                                     3  ~34     'Vehicle+name+is+'
         59        ROPE_ADD                                      1  ~34     ~34, !1
         60        ROPE_END                                      2  ~33     ~34, '+%0A'
         61        ECHO                                                     ~33
  113    62        ROPE_INIT                                     3  ~37     'Vehicle+Model+is+'
         63        ROPE_ADD                                      1  ~37     ~37, !8
         64        ROPE_END                                      2  ~36     ~37, '+%0A'
         65        ECHO                                                     ~36
  114    66        ROPE_INIT                                     3  ~40     'Vehich+type+is+'
         67        ROPE_ADD                                      1  ~40     ~40, !7
         68        ROPE_END                                      2  ~39     ~40, '+%0A'
         69        ECHO                                                     ~39
  116    70        INIT_FCALL                                               'printf'
         71        SEND_VAL                                                 '%0A%0A'
         72        DO_ICALL                                                 
  117    73        ECHO                                                     'Printing+Vehicle+Mode%0A'
  118    74        ECHO                                                     '%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0A'
  119    75        INIT_FCALL                                               'print_r'
         76        SEND_VAR                                                 !2
         77        DO_ICALL                                                 
  121    78        INIT_FCALL                                               'printf'
         79        SEND_VAL                                                 '%0A%0A'
         80        DO_ICALL                                                 
  122    81        ECHO                                                     'Printing+Vehicle+Features%0A'
  123    82        ECHO                                                     '%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0A'
  124    83        INIT_FCALL                                               'print_r'
         84        SEND_VAR                                                 !6
         85        DO_ICALL                                                 
  126    86        INIT_FCALL                                               'printf'
         87        SEND_VAL                                                 '%0A%0A'
         88        DO_ICALL                                                 
  128    89        ECHO                                                     'Printing+Vehicle+Identification%0A'
  129    90        ECHO                                                     '%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0A'
  130    91        INIT_FCALL                                               'print_r'
         92        SEND_VAR                                                 !5
         93        DO_ICALL                                                 
  133    94        INIT_FCALL                                               'printf'
         95        SEND_VAL                                                 '%0A%0A'
         96        DO_ICALL                                                 
  134    97      > RETURN                                                   1

Class Vehicle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TkGZg
function name:  __construct
number of ops:  9
compiled vars:  !0 = $name, !1 = $model, !2 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   18     3        INIT_METHOD_CALL                                         'create_vehicle'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0          
   19     8      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/TkGZg
function name:  __get
number of ops:  8
compiled vars:  !0 = $variable, !1 = $get_variable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        ISSET_ISEMPTY_PROP_OBJ                           ~2      !0
          2        BOOL_NOT                                         ~3      ~2
          3      > JMPZ                                                     ~3, ->6
   24     4    >   FETCH_OBJ_R                                      ~4      !0
          5        ASSIGN                                                   !1, ~4
   27     6    > > RETURN                                                   !1
   28     7*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TkGZg
function name:  __set
number of ops:  5
compiled vars:  !0 = $variable, !1 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        ASSIGN_OBJ                                               !0
          3        OP_DATA                                                  !1
   33     4      > RETURN                                                   null

End of function __set

Function create_vehicle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TkGZg
function name:  create_vehicle
number of ops:  16
compiled vars:  !0 = $name, !1 = $model, !2 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   37     3        INIT_METHOD_CALL                                         '__set'
          4        SEND_VAL_EX                                              '_name'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   38     7        INIT_METHOD_CALL                                         '__set'
          8        SEND_VAL_EX                                              '_model'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
   39    11        INIT_METHOD_CALL                                         '__set'
         12        SEND_VAL_EX                                              '_type'
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
   40    15      > RETURN                                                   null

End of function create_vehicle

End of class Vehicle.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
217.98 ms | 1024 KiB | 15 Q