3v4l.org

run code in 200+ 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->state . PHP_EOL; $GLOBALS['a']->state++; echo $b->a->state . PHP_EOL; $GLOBALS['a'] = new A(); echo $b->a->state . PHP_EOL;
based on l6ai9
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eTaI5
function name:  (null)
number of ops:  30
compiled vars:  !0 = $b
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  15     0  E >   NEW                                              $3      :57
         1        DO_FCALL                                      0          
         2        FETCH_W                      global              $1      'GLOBALS'
         3        ASSIGN_ADD                                    0          $1, 'a'
         4        OP_DATA                                                  $3
  17     5        NEW                                              $5      :49
         6        DO_FCALL                                      0          
         7        QM_ASSIGN                                                !0
  18     8        FETCH_OBJ_R                                      ~8      !0, 'a'
         9        FETCH_OBJ_R                                      ~9      ~8, 'state'
        10        CONCAT                                           ~10     ~9, '%0A'
        11        ASSIGN_OBJ                                               ~10
  20    12        FETCH_RW                     global              $11     'GLOBALS'
        13        FETCH_DIM_RW                                     $12     $11, 'a'
        14        POST_INC_OBJ                                     ~13     $12, 'state'
        15        FREE                                                     ~13
  21    16        FETCH_OBJ_R                                      ~14     !0, 'a'
        17        FETCH_OBJ_R                                      ~15     ~14, 'state'
        18        CONCAT                                           ~16     ~15, '%0A'
        19        ASSIGN_OBJ                                               ~16
  23    20        NEW                                              $19     :32
        21        DO_FCALL                                      0          
        22        FETCH_W                      global              $17     'GLOBALS'
        23        ASSIGN_ADD                                    0          $17, 'a'
        24        OP_DATA                                                  $19
  24    25        FETCH_OBJ_R                                      ~21     !0, 'a'
        26        FETCH_OBJ_R                                      ~22     ~21, 'state'
        27        CONCAT                                           ~23     ~22, '%0A'
        28        ASSIGN_OBJ                                               ~23
        29      > 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/eTaI5
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_SUB                                    0          'a'
         3        OP_DATA                                                  ~2
  12     4      > RETURN                                                   null

End of function __construct

End of class B.

Generated using Vulcan Logic Dumper, using php 7.4.0