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 ); 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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/35Aum
function name:  (null)
number of ops:  11
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                                                 
         10      > RETURN                                                   1

Class MyObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/35Aum
function name:  __construct
number of ops:  14
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
   11     7        FETCH_OBJ_R                                      ~6      '_id'
          8        FETCH_THIS                                       $8      
          9        MAKE_REF                                         $9      $8
         10        FETCH_STATIC_PROP_W          unknown             $5      '_register'
         11        FETCH_DIM_W                                      $7      $5, ~6
         12        ASSIGN_REF                                               $7, $9
   12    13      > 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/35Aum
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:
150.42 ms | 1396 KiB | 15 Q