3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GameObject { protected $name; protected $description; public function __construct($name, $description) { $this->name = $name; $this->description = $description; } public function display() { echo "\n Name: " . $this->name; echo "\n Description: " . $this->description; } } class Character extends GameObject { private $url; public function __construct($name, $description, $url) { parent::__construct ($name, $description); $this->url = $url; } public function display() { parent::display (); echo "\n Url: " . $this->url; } } class Obstacle extends GameObject { private $movable; private $hittable; public function __construct($name, $description, $movable, $hittable) { parent::__construct ($name, $description); $this->movable = $movable; $this->hittable = $hittable; } public function display() { parent::display (); echo "\n Movable: " . $this->movable; echo "\n Hittable: " . $this->hittable; } } // Creating object array $objects = array(); $objects['Mario'] = new Character( 'Mario', 'A short, pudgy, plumber who resides in the Mushroom Kingdom.', ' https://upload.wikimedia.org/wikipedia/en/9/99/MarioSMBW.png' ); $objects['Luigi'] = new Character( 'Luigi', 'Younger brother of Mario.', 'https://upload.wikimedia.org/wikipedia/en/f/f1/LuigiNSMBW.png' ); $objects['Bowser'] = new Character( 'Bowser', 'Bowser is the leader and most powerful of the turtle-like Koopa race.', 'https://upload.wikimedia.org/wikipedia/en/e/ec/Bowser_-_New_Super_Mario_Bros_2.png' ); $objects['Coin'] = new Obstacle( 'Coin', 'Coins are added to each level, which reward an extra life.', 'No', 'Yes' ); $objects['Brick'] = new Obstacle( 'Brick', 'Characters cannot get pass through the bricks.', 'No', 'No' ); echo"\nSuperMario: Introduction of Game Objects \n"; $check = 'y'; while ($check == 'y'){ $searchObject = readline("\nEnter the name of the object: \n"); if (isset($objects[$searchObject])) { $objects[$searchObject]->display(); } else { echo "\n Sorry, object not found\n"; } echo "\n"; $check=readline("Do you want to continue? (y/n): "); } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 41
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 51
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 41
Branch analysis from position: 59
Branch analysis from position: 41
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 41
Branch analysis from position: 59
Branch analysis from position: 41
filename:       /in/JcJNT
function name:  (null)
number of ops:  60
compiled vars:  !0 = $objects, !1 = $check, !2 = $searchObject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   ASSIGN                                                   !0, <array>
   45     1        NEW                                              $5      'Character'
   46     2        SEND_VAL_EX                                              'Mario'
   47     3        SEND_VAL_EX                                              'A+short%2C+pudgy%2C+plumber+who+resides+in+the+Mushroom+Kingdom.'
   48     4        SEND_VAL_EX                                              '+https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fen%2F9%2F99%2FMarioSMBW.png'
          5        DO_FCALL                                      0          
   45     6        ASSIGN_DIM                                               !0, 'Mario'
   48     7        OP_DATA                                                  $5
   50     8        NEW                                              $8      'Character'
   51     9        SEND_VAL_EX                                              'Luigi'
   52    10        SEND_VAL_EX                                              'Younger+brother+of+Mario.'
   53    11        SEND_VAL_EX                                              'https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fen%2Ff%2Ff1%2FLuigiNSMBW.png'
         12        DO_FCALL                                      0          
   50    13        ASSIGN_DIM                                               !0, 'Luigi'
   53    14        OP_DATA                                                  $8
   55    15        NEW                                              $11     'Character'
   56    16        SEND_VAL_EX                                              'Bowser'
   57    17        SEND_VAL_EX                                              'Bowser+is+the+leader+and+most+powerful+of+the+turtle-like+Koopa+race.'
   58    18        SEND_VAL_EX                                              'https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fen%2Fe%2Fec%2FBowser_-_New_Super_Mario_Bros_2.png'
         19        DO_FCALL                                      0          
   55    20        ASSIGN_DIM                                               !0, 'Bowser'
   58    21        OP_DATA                                                  $11
   60    22        NEW                                              $14     'Obstacle'
   61    23        SEND_VAL_EX                                              'Coin'
   62    24        SEND_VAL_EX                                              'Coins+are+added+to+each+level%2C+which+reward+an+extra+life.'
   63    25        SEND_VAL_EX                                              'No'
   64    26        SEND_VAL_EX                                              'Yes'
         27        DO_FCALL                                      0          
   60    28        ASSIGN_DIM                                               !0, 'Coin'
   64    29        OP_DATA                                                  $14
   66    30        NEW                                              $17     'Obstacle'
   67    31        SEND_VAL_EX                                              'Brick'
   68    32        SEND_VAL_EX                                              'Characters+cannot+get+pass+through+the+bricks.'
   69    33        SEND_VAL_EX                                              'No'
   70    34        SEND_VAL_EX                                              'No'
         35        DO_FCALL                                      0          
   66    36        ASSIGN_DIM                                               !0, 'Brick'
   70    37        OP_DATA                                                  $17
   73    38        ECHO                                                     '%0ASuperMario%3A+Introduction+of+Game+Objects+%0A'
   74    39        ASSIGN                                                   !1, 'y'
   75    40      > JMP                                                      ->57
   76    41    >   INIT_FCALL_BY_NAME                                       'readline'
         42        SEND_VAL_EX                                              '%0AEnter+the+name+of+the+object%3A+%0A'
         43        DO_FCALL                                      0  $20     
         44        ASSIGN                                                   !2, $20
   77    45        ISSET_ISEMPTY_DIM_OBJ                         0          !0, !2
         46      > JMPZ                                                     ~22, ->51
   78    47    >   FETCH_DIM_R                                      ~23     !0, !2
         48        INIT_METHOD_CALL                                         ~23, 'display'
         49        DO_FCALL                                      0          
         50      > JMP                                                      ->52
   80    51    >   ECHO                                                     '%0A+Sorry%2C+object+not+found%0A'
   82    52    >   ECHO                                                     '%0A'
   83    53        INIT_FCALL_BY_NAME                                       'readline'
         54        SEND_VAL_EX                                              'Do+you+want+to+continue%3F+%28y%2Fn%29%3A+'
         55        DO_FCALL                                      0  $25     
         56        ASSIGN                                                   !1, $25
   75    57    >   IS_EQUAL                                                 !1, 'y'
         58      > JMPNZ                                                    ~27, ->41
   86    59    > > RETURN                                                   1

Class GameObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JcJNT
function name:  __construct
number of ops:  7
compiled vars:  !0 = $name, !1 = $description
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN_OBJ                                               'name'
          3        OP_DATA                                                  !0
    8     4        ASSIGN_OBJ                                               'description'
          5        OP_DATA                                                  !1
    9     6      > RETURN                                                   null

End of function __construct

Function display:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JcJNT
function name:  display
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        CONCAT                                           ~1      '%0A+Name%3A+', ~0
          2        ECHO                                                     ~1
   12     3        FETCH_OBJ_R                                      ~2      'description'
          4        CONCAT                                           ~3      '%0A+Description%3A+', ~2
          5        ECHO                                                     ~3
   13     6      > RETURN                                                   null

End of function display

End of class GameObject.

Class Character:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JcJNT
function name:  __construct
number of ops:  10
compiled vars:  !0 = $name, !1 = $description, !2 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   19     3        INIT_STATIC_METHOD_CALL                                  
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
   20     7        ASSIGN_OBJ                                               'url'
          8        OP_DATA                                                  !2
   21     9      > RETURN                                                   null

End of function __construct

Function display:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JcJNT
function name:  display
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_STATIC_METHOD_CALL                                  'display'
          1        DO_FCALL                                      0          
   24     2        FETCH_OBJ_R                                      ~1      'url'
          3        CONCAT                                           ~2      '%0A+Url%3A+', ~1
          4        ECHO                                                     ~2
   25     5      > RETURN                                                   null

End of function display

End of class Character.

Class Obstacle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JcJNT
function name:  __construct
number of ops:  13
compiled vars:  !0 = $name, !1 = $description, !2 = $movable, !3 = $hittable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   32     4        INIT_STATIC_METHOD_CALL                                  
          5        SEND_VAR_EX                                              !0
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   33     8        ASSIGN_OBJ                                               'movable'
          9        OP_DATA                                                  !2
   34    10        ASSIGN_OBJ                                               'hittable'
         11        OP_DATA                                                  !3
   35    12      > RETURN                                                   null

End of function __construct

Function display:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JcJNT
function name:  display
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_STATIC_METHOD_CALL                                  'display'
          1        DO_FCALL                                      0          
   38     2        FETCH_OBJ_R                                      ~1      'movable'
          3        CONCAT                                           ~2      '%0A+Movable%3A+', ~1
          4        ECHO                                                     ~2
   39     5        FETCH_OBJ_R                                      ~3      'hittable'
          6        CONCAT                                           ~4      '%0A+Hittable%3A+', ~3
          7        ECHO                                                     ~4
   40     8      > RETURN                                                   null

End of function display

End of class Obstacle.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.95 ms | 1407 KiB | 13 Q