3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { private $foo; public function __construct() { $this->foo = "base foo"; } public final function getFoo() { var_dump($this); return $this->foo; } } class Derived extends Base { public $foo; public function __construct($type) { parent::__construct(); $this->foo = "derived foo"; $this->somethingUndefined = "dynamically declared"; } } $base = new Base(); var_dump($base->getFoo()); $derived = new Derived(0); var_dump($derived->getFoo()); $clonedDerived = clone $derived; var_dump($clonedDerived->getFoo());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ob9m7
function name:  (null)
number of ops:  25
compiled vars:  !0 = $base, !1 = $derived, !2 = $clonedDerived
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $3      'Base'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   29     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'getFoo'
          5        DO_FCALL                                      0  $6      
          6        SEND_VAR                                                 $6
          7        DO_ICALL                                                 
   30     8        NEW                                              $8      'Derived'
          9        SEND_VAL_EX                                              0
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $8
   31    12        INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !1, 'getFoo'
         14        DO_FCALL                                      0  $11     
         15        SEND_VAR                                                 $11
         16        DO_ICALL                                                 
   32    17        CLONE                                            ~13     !1
         18        ASSIGN                                                   !2, ~13
   33    19        INIT_FCALL                                               'var_dump'
         20        INIT_METHOD_CALL                                         !2, 'getFoo'
         21        DO_FCALL                                      0  $15     
         22        SEND_VAR                                                 $15
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Class Base:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ob9m7
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN_OBJ                                               'foo'
          1        OP_DATA                                                  'base+foo'
    9     2      > RETURN                                                   null

End of function __construct

Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ob9m7
function name:  getFoo
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   13     4        FETCH_OBJ_R                                      ~2      'foo'
          5      > RETURN                                                   ~2
   14     6*     > RETURN                                                   null

End of function getfoo

End of class Base.

Class Derived:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ob9m7
function name:  __construct
number of ops:  8
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        INIT_STATIC_METHOD_CALL                                  
          2        DO_FCALL                                      0          
   23     3        ASSIGN_OBJ                                               'foo'
          4        OP_DATA                                                  'derived+foo'
   24     5        ASSIGN_OBJ                                               'somethingUndefined'
          6        OP_DATA                                                  'dynamically+declared'
   25     7      > RETURN                                                   null

End of function __construct

Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ob9m7
function name:  getFoo
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   13     4        FETCH_OBJ_R                                      ~2      'foo'
          5      > RETURN                                                   ~2
   14     6*     > RETURN                                                   null

End of function getfoo

End of class Derived.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.62 ms | 1400 KiB | 15 Q