3v4l.org

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

Class A: [no user functions]
Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l6ai9
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_R                      global              ~1      'GLOBALS'
          1        FETCH_DIM_R                                      ~2      ~1, 'a'
          2        ASSIGN_OBJ                                               'a'
          3        OP_DATA                                                  ~2
   12     4      > RETURN                                                   null

End of function __construct

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.63 ms | 1395 KiB | 13 Q