3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ParentClass { private $name = 'Parent'; public function getName() { return $this->name; } public function setName($name) { $this->name = $name; } } class Child extends ParentClass { public $name = 'Child'; } $parent = new ParentClass(); echo "\nParent name: " . $parent->getName(); echo "\nSetting parent name to 'old'"; $parent->setName('old'); echo "\nParent name after change: " . $parent->getName(); $child = new Child(); echo "\nChild name by getter: " . $child->getName(); echo "\nChild name by prop: " . $child->name; $reflect = new ReflectionClass($child); $props = $reflect->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE); foreach ($props as $prop) { echo "\nChild property: " . $prop->getName(); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 40
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/HsIQT
function name:  (null)
number of ops:  42
compiled vars:  !0 = $parent, !1 = $child, !2 = $reflect, !3 = $props, !4 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $5      'ParentClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   15     3        INIT_METHOD_CALL                                         !0, 'getName'
          4        DO_FCALL                                      0  $8      
          5        CONCAT                                           ~9      '%0AParent+name%3A+', $8
          6        ECHO                                                     ~9
   16     7        ECHO                                                     '%0ASetting+parent+name+to+%27old%27'
          8        INIT_METHOD_CALL                                         !0, 'setName'
          9        SEND_VAL_EX                                              'old'
         10        DO_FCALL                                      0          
   17    11        INIT_METHOD_CALL                                         !0, 'getName'
         12        DO_FCALL                                      0  $11     
         13        CONCAT                                           ~12     '%0AParent+name+after+change%3A+', $11
         14        ECHO                                                     ~12
   19    15        NEW                                              $13     'Child'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !1, $13
   20    18        INIT_METHOD_CALL                                         !1, 'getName'
         19        DO_FCALL                                      0  $16     
         20        CONCAT                                           ~17     '%0AChild+name+by+getter%3A+', $16
         21        ECHO                                                     ~17
   21    22        FETCH_OBJ_R                                      ~18     !1, 'name'
         23        CONCAT                                           ~19     '%0AChild+name+by+prop%3A+', ~18
         24        ECHO                                                     ~19
   22    25        NEW                                              $20     'ReflectionClass'
         26        SEND_VAR_EX                                              !1
         27        DO_FCALL                                      0          
         28        ASSIGN                                                   !2, $20
   23    29        INIT_METHOD_CALL                                         !2, 'getProperties'
         30        SEND_VAL_EX                                              7
         31        DO_FCALL                                      0  $23     
         32        ASSIGN                                                   !3, $23
   25    33      > FE_RESET_R                                       $25     !3, ->40
         34    > > FE_FETCH_R                                               $25, !4, ->40
   26    35    >   INIT_METHOD_CALL                                         !4, 'getName'
         36        DO_FCALL                                      0  $26     
         37        CONCAT                                           ~27     '%0AChild+property%3A+', $26
         38        ECHO                                                     ~27
   25    39      > JMP                                                      ->34
         40    >   FE_FREE                                                  $25
   27    41      > RETURN                                                   1

Class ParentClass:
Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HsIQT
function name:  getName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function getname

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

End of function setname

End of class ParentClass.

Class Child:
Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HsIQT
function name:  getName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function getname

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

End of function setname

End of class Child.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.7 ms | 1399 KiB | 13 Q