3v4l.org

run code in 300+ PHP versions simultaneously
<?php class B { public $var; public function __construct($var) { $this->var = $var; } } class A { public $class; public function __construct(B $class) { $this->class = $class; } } $b = new B('test'); $a = new A($b); echo $b->var."\n"; echo $a->class->var."\n"; $b->var = 'test2'; echo $b->var."\n"; echo $a->class->var;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LqgTc
function name:  (null)
number of ops:  24
compiled vars:  !0 = $b, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $2      'B'
          1        SEND_VAL_EX                                              'test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   16     4        NEW                                              $5      'A'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   18     8        FETCH_OBJ_R                                      ~8      !0, 'var'
          9        CONCAT                                           ~9      ~8, '%0A'
         10        ECHO                                                     ~9
   19    11        FETCH_OBJ_R                                      ~10     !1, 'class'
         12        FETCH_OBJ_R                                      ~11     ~10, 'var'
         13        CONCAT                                           ~12     ~11, '%0A'
         14        ECHO                                                     ~12
   21    15        ASSIGN_OBJ                                               !0, 'var'
         16        OP_DATA                                                  'test2'
   23    17        FETCH_OBJ_R                                      ~14     !0, 'var'
         18        CONCAT                                           ~15     ~14, '%0A'
         19        ECHO                                                     ~15
   24    20        FETCH_OBJ_R                                      ~16     !1, 'class'
         21        FETCH_OBJ_R                                      ~17     ~16, 'var'
         22        ECHO                                                     ~17
         23      > RETURN                                                   1

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

End of function __construct

End of class B.

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

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.15 ms | 1424 KiB | 13 Q