3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL);class RefArray implements ArrayAccess { public $array; public function &offsetGet($key) { return $this->array[$key]; } public function offsetSet($key, $value) { $this->array[$key] = $value; } public function offsetExists($key) { return isset($this->array[$key]); } public function offsetUnset($key) { unset($this->array[$key]); }}$obj = new stdClass;$obj->prop1 = 'abc';$obj->prop2 =& $obj->prop1;$obj->prop2 .= 'xyz';var_dump($obj->prop1);$obj->prop3 = 1;$obj->prop4 =& $obj->prop3;++$obj->prop4;var_dump($obj->prop3);$arr = new RefArray;$arr[0] = 'abc';$arr[1] =& $arr[0];$arr[1] .= 'xyz';var_dump($arr[0]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ysm4a
function name:  (null)
number of ops:  46
compiled vars:  !0 = $obj, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
          3        DECLARE_CLASS                                            'refarray'
          4        NEW                                              $3      'stdClass'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
          7        ASSIGN_OBJ                                               !0, 'prop1'
          8        OP_DATA                                                  'abc'
          9        FETCH_OBJ_W                                      $8      !0, 'prop1'
         10        MAKE_REF                                         $9      $8
         11        ASSIGN_OBJ_REF                                           !0, 'prop2'
         12        OP_DATA                                                  $9
         13        ASSIGN_OBJ_OP                                 8          !0, 'prop2'
         14        OP_DATA                                                  'xyz'
         15        INIT_FCALL                                               'var_dump'
         16        FETCH_OBJ_R                                      ~11     !0, 'prop1'
         17        SEND_VAL                                                 ~11
         18        DO_ICALL                                                 
         19        ASSIGN_OBJ                                               !0, 'prop3'
         20        OP_DATA                                                  1
         21        FETCH_OBJ_W                                      $15     !0, 'prop3'
         22        MAKE_REF                                         $16     $15
         23        ASSIGN_OBJ_REF                                           !0, 'prop4'
         24        OP_DATA                                                  $16
         25        PRE_INC_OBJ                                              !0, 'prop4'
         26        INIT_FCALL                                               'var_dump'
         27        FETCH_OBJ_R                                      ~18     !0, 'prop3'
         28        SEND_VAL                                                 ~18
         29        DO_ICALL                                                 
         30        NEW                                              $20     'RefArray'
         31        DO_FCALL                                      0          
         32        ASSIGN                                                   !1, $20
         33        ASSIGN_DIM                                               !1, 0
         34        OP_DATA                                                  'abc'
         35        FETCH_DIM_W                                      $25     !1, 0
         36        MAKE_REF                                         $26     $25
         37        FETCH_DIM_W                                      $24     !1, 1
         38        ASSIGN_REF                                               $24, $26
         39        ASSIGN_DIM_OP                .=               8          !1, 1
         40        OP_DATA                                                  'xyz'
         41        INIT_FCALL                                               'var_dump'
         42        FETCH_DIM_R                                      ~29     !1, 0
         43        SEND_VAL                                                 ~29
         44        DO_ICALL                                                 
         45      > RETURN                                                   1

Class RefArray:
Function offsetget:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/Ysm4a
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        FETCH_OBJ_W                                      $1      'array'
          2        FETCH_DIM_W                                      $2      $1, !0
          3      > RETURN_BY_REF                                            $2
          4*     > RETURN_BY_REF                                            null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ysm4a
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_OBJ_W                                      $2      'array'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
          5      > RETURN                                                   null

End of function offsetset

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ysm4a
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        FETCH_OBJ_IS                                     ~1      'array'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function offsetexists

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ysm4a
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        FETCH_OBJ_UNSET                                  $1      'array'
          2        UNSET_DIM                                                $1, !0
          3      > RETURN                                                   null

End of function offsetunset

End of class RefArray.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.75 ms | 1400 KiB | 17 Q