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); var_export($props);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MKFaZ
function name:  (null)
number of ops:  37
compiled vars:  !0 = $parent, !1 = $child, !2 = $reflect, !3 = $props
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $4      'ParentClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   15     3        INIT_METHOD_CALL                                         !0, 'getName'
          4        DO_FCALL                                      0  $7      
          5        CONCAT                                           ~8      '%0AParent+name%3A+', $7
          6        ECHO                                                     ~8
   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  $10     
         13        CONCAT                                           ~11     '%0AParent+name+after+change%3A+', $10
         14        ECHO                                                     ~11
   19    15        NEW                                              $12     'Child'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !1, $12
   20    18        INIT_METHOD_CALL                                         !1, 'getName'
         19        DO_FCALL                                      0  $15     
         20        CONCAT                                           ~16     '%0AChild+name+by+getter%3A+', $15
         21        ECHO                                                     ~16
   21    22        FETCH_OBJ_R                                      ~17     !1, 'name'
         23        CONCAT                                           ~18     '%0AChild+name+by+prop%3A+', ~17
         24        ECHO                                                     ~18
   22    25        NEW                                              $19     'ReflectionClass'
         26        SEND_VAR_EX                                              !1
         27        DO_FCALL                                      0          
         28        ASSIGN                                                   !2, $19
   23    29        INIT_METHOD_CALL                                         !2, 'getProperties'
         30        SEND_VAL_EX                                              7
         31        DO_FCALL                                      0  $22     
         32        ASSIGN                                                   !3, $22
   25    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Class ParentClass:
Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MKFaZ
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/MKFaZ
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/MKFaZ
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/MKFaZ
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:
163.35 ms | 1400 KiB | 15 Q