3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { public static $foo = 'foo'; public $thisvars = array(); public $selfvars = array(); public $staticvars = array(); public function __construct() { $this->addFoo(); } public function addFoo() { $this->selfvars[] = self::$foo; $this->staticvars[] = static::$foo; $this->thisvars[] = $this::$foo; } } class B extends A { public static $foo = 'bar'; public function __construct() { parent::__construct(); $this->addFoo(); } } $b = new B; print_r($b->selfvars); print_r($b->staticvars); print_r($b->thisvars); class C { public static $foo = 'foo'; public $vars = array(); public function __construct() { $this->addFoo(__CLASS__); } public function addFoo($class) { $this->vars[] = $class::$foo; } } class D extends C { public static $foo = 'bar'; public function __construct() { parent::__construct(); $this->addFoo(__CLASS__); } } $d = new D; print_r($d->vars);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TqUUf
function name:  (null)
number of ops:  23
compiled vars:  !0 = $b, !1 = $d
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   NEW                                                  $2      'B'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $2
   32     3        INIT_FCALL                                                   'print_r'
          4        FETCH_OBJ_R                                          ~5      !0, 'selfvars'
          5        SEND_VAL                                                     ~5
          6        DO_ICALL                                                     
   33     7        INIT_FCALL                                                   'print_r'
          8        FETCH_OBJ_R                                          ~7      !0, 'staticvars'
          9        SEND_VAL                                                     ~7
         10        DO_ICALL                                                     
   34    11        INIT_FCALL                                                   'print_r'
         12        FETCH_OBJ_R                                          ~9      !0, 'thisvars'
         13        SEND_VAL                                                     ~9
         14        DO_ICALL                                                     
   60    15        NEW                                                  $11     'D'
         16        DO_FCALL                                          0          
         17        ASSIGN                                                       !1, $11
   61    18        INIT_FCALL                                                   'print_r'
         19        FETCH_OBJ_R                                          ~14     !1, 'vars'
         20        SEND_VAL                                                     ~14
         21        DO_ICALL                                                     
         22      > RETURN                                                       1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TqUUf
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   INIT_METHOD_CALL                                             'addFoo'
          1        DO_FCALL                                          0          
   12     2      > RETURN                                                       null

End of function __construct

Function addfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TqUUf
function name:  addFoo
number of ops:  15
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   FETCH_STATIC_PROP_R              unknown             ~2      'foo'
          1        FETCH_OBJ_W                                          $0      'selfvars'
          2        ASSIGN_DIM                                                   $0
          3        OP_DATA                                                      ~2
   16     4        FETCH_STATIC_PROP_R              unknown             ~5      'foo'
          5        FETCH_OBJ_W                                          $3      'staticvars'
          6        ASSIGN_DIM                                                   $3
          7        OP_DATA                                                      ~5
   17     8        FETCH_THIS                                           ~8      
          9        FETCH_CLASS                                       0  $9      ~8
         10        FETCH_STATIC_PROP_R              unknown             ~10     'foo'
         11        FETCH_OBJ_W                                          $6      'thisvars'
         12        ASSIGN_DIM                                                   $6
         13        OP_DATA                                                      ~10
   18    14      > RETURN                                                       null

End of function addfoo

End of class A.

Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TqUUf
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   INIT_STATIC_METHOD_CALL                                      
          1        DO_FCALL                                          0          
   27     2        INIT_METHOD_CALL                                             'addFoo'
          3        DO_FCALL                                          0          
   28     4      > RETURN                                                       null

End of function __construct

Function addfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TqUUf
function name:  addFoo
number of ops:  15
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   FETCH_STATIC_PROP_R              unknown             ~2      'foo'
          1        FETCH_OBJ_W                                          $0      'selfvars'
          2        ASSIGN_DIM                                                   $0
          3        OP_DATA                                                      ~2
   16     4        FETCH_STATIC_PROP_R              unknown             ~5      'foo'
          5        FETCH_OBJ_W                                          $3      'staticvars'
          6        ASSIGN_DIM                                                   $3
          7        OP_DATA                                                      ~5
   17     8        FETCH_THIS                                           ~8      
          9        FETCH_CLASS                                       0  $9      ~8
         10        FETCH_STATIC_PROP_R              unknown             ~10     'foo'
         11        FETCH_OBJ_W                                          $6      'thisvars'
         12        ASSIGN_DIM                                                   $6
         13        OP_DATA                                                      ~10
   18    14      > RETURN                                                       null

End of function addfoo

End of class B.

Class C:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TqUUf
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   42     0  E >   INIT_METHOD_CALL                                             'addFoo'
          1        SEND_VAL_EX                                                  'C'
          2        DO_FCALL                                          0          
   43     3      > RETURN                                                       null

End of function __construct

Function addfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TqUUf
function name:  addFoo
number of ops:  7
compiled vars:  !0 = $class
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   45     0  E >   RECV                                                 !0      
   46     1        FETCH_CLASS                                       0  $3      !0
          2        FETCH_STATIC_PROP_R              unknown             ~4      'foo'
          3        FETCH_OBJ_W                                          $1      'vars'
          4        ASSIGN_DIM                                                   $1
          5        OP_DATA                                                      ~4
   47     6      > RETURN                                                       null

End of function addfoo

End of class C.

Class D:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TqUUf
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   55     0  E >   INIT_STATIC_METHOD_CALL                                      
          1        DO_FCALL                                          0          
   56     2        INIT_METHOD_CALL                                             'addFoo'
          3        SEND_VAL_EX                                                  'D'
          4        DO_FCALL                                          0          
   57     5      > RETURN                                                       null

End of function __construct

Function addfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TqUUf
function name:  addFoo
number of ops:  7
compiled vars:  !0 = $class
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   45     0  E >   RECV                                                 !0      
   46     1        FETCH_CLASS                                       0  $3      !0
          2        FETCH_STATIC_PROP_R              unknown             ~4      'foo'
          3        FETCH_OBJ_W                                          $1      'vars'
          4        ASSIGN_DIM                                                   $1
          5        OP_DATA                                                      ~4
   47     6      > RETURN                                                       null

End of function addfoo

End of class D.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.45 ms | 2180 KiB | 14 Q