3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements ArrayAccess { private $data = array(); /** Array Access */ public function offsetExists($offset) { return isset($this->data[$offset]); } public function &offsetGet($offset) { return $this->data[$offset]; } public function offsetSet($offset, $value) { $this->data[$offset] = $value; } public function offsetUnset($offset) { unset($this->data[$offset]); } } class Test2 extends ArrayObject { public function &offsetGet($offset) { $t =& parent::offsetGet($offset); return $t; } } $t = new Test(); $t['test'] = array(1,2,3,4); echo serialize($t)."\n"; $t['test'][] = 5; echo serialize($t)."\n"; $t = new Test2(); $t['test'] = array(1,2,3,4); echo serialize($t)."\n"; $t['test'][] = 5; echo serialize($t)."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qdJEZ
function name:  (null)
number of ops:  38
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'test'
   36     1        NEW                                              $1      'Test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   37     4        ASSIGN_DIM                                               !0, 'test'
          5        OP_DATA                                                  <array>
   38     6        INIT_FCALL                                               'serialize'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9        CONCAT                                           ~6      $5, '%0A'
         10        ECHO                                                     ~6
   39    11        FETCH_DIM_W                                      $7      !0, 'test'
         12        ASSIGN_DIM                                               $7
         13        OP_DATA                                                  5
   40    14        INIT_FCALL                                               'serialize'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $9      
         17        CONCAT                                           ~10     $9, '%0A'
         18        ECHO                                                     ~10
   42    19        NEW                                              $11     'Test2'
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !0, $11
   43    22        ASSIGN_DIM                                               !0, 'test'
         23        OP_DATA                                                  <array>
   44    24        INIT_FCALL                                               'serialize'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $15     
         27        CONCAT                                           ~16     $15, '%0A'
         28        ECHO                                                     ~16
   45    29        FETCH_DIM_W                                      $17     !0, 'test'
         30        ASSIGN_DIM                                               $17
         31        OP_DATA                                                  5
   46    32        INIT_FCALL                                               'serialize'
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                         $19     
         35        CONCAT                                           ~20     $19, '%0A'
         36        ECHO                                                     ~20
         37      > RETURN                                                   1

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

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/qdJEZ
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_W                                      $1      'data'
          2        FETCH_DIM_W                                      $2      $1, !0
          3      > RETURN_BY_REF                                            $2
   15     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/qdJEZ
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        FETCH_OBJ_W                                      $2      'data'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   20     5      > RETURN                                                   null

End of function offsetset

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

End of function offsetunset

End of class Test.

Class Test2:
Function offsetget:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/qdJEZ
function name:  offsetGet
number of ops:  7
compiled vars:  !0 = $offset, !1 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        INIT_STATIC_METHOD_CALL                                  'offsetGet'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN_REF                                               !1, $2
   32     5      > RETURN_BY_REF                                            !1
   33     6*     > RETURN_BY_REF                                            null

End of function offsetget

End of class Test2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.28 ms | 1392 KiB | 15 Q