3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyObject{ public static $_register = array(); public $_id = -1; public $_value = ''; function __construct( $value ){ $this->_value = $value; $this->_id = count( self::$_register ); var_dump($this); self::$_register[ $this->_id ] = &$this; // I also tried '= &$this' } function foo(){ // outputs 'id : value' echo $this->_id.' : ' . $this->_value. PHP_EOL; } } $test = new MyObject( 'hihi' ); $test->foo(); var_dump(MyObject::$_register); MyObject::$_register[0]->_value='bar'; var_dump($test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XjOgP
function name:  (null)
number of ops:  18
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $1      'MyObject'
          1        SEND_VAL_EX                                              'hihi'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   20     4        INIT_METHOD_CALL                                         !0, 'foo'
          5        DO_FCALL                                      0          
   21     6        INIT_FCALL                                               'var_dump'
          7        FETCH_STATIC_PROP_R          unknown             ~5      '_register'
          8        SEND_VAL                                                 ~5
          9        DO_ICALL                                                 
   22    10        FETCH_STATIC_PROP_W          unknown             $7      '_register'
         11        FETCH_DIM_W                                      $8      $7, 0
         12        ASSIGN_OBJ                                               $8, '_value'
         13        OP_DATA                                                  'bar'
   23    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class MyObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XjOgP
function name:  __construct
number of ops:  18
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               '_value'
          2        OP_DATA                                                  !0
    9     3        FETCH_STATIC_PROP_R          unknown             ~3      '_register'
          4        COUNT                                            ~4      ~3
          5        ASSIGN_OBJ                                               '_id'
          6        OP_DATA                                                  ~4
   10     7        INIT_FCALL                                               'var_dump'
          8        FETCH_THIS                                       ~5      
          9        SEND_VAL                                                 ~5
         10        DO_ICALL                                                 
   11    11        FETCH_OBJ_R                                      ~8      '_id'
         12        FETCH_THIS                                       $10     
         13        MAKE_REF                                         $11     $10
         14        FETCH_STATIC_PROP_W          unknown             $7      '_register'
         15        FETCH_DIM_W                                      $9      $7, ~8
         16        ASSIGN_REF                                               $9, $11
   12    17      > RETURN                                                   null

End of function __construct

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XjOgP
function name:  foo
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      '_id'
          1        CONCAT                                           ~1      ~0, '+%3A+'
          2        FETCH_OBJ_R                                      ~2      '_value'
          3        CONCAT                                           ~3      ~1, ~2
          4        CONCAT                                           ~4      ~3, '%0A'
          5        ECHO                                                     ~4
   16     6      > RETURN                                                   null

End of function foo

End of class MyObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.29 ms | 1400 KiB | 15 Q