3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test implements ArrayAccess { protected $_array = array(); public function offsetGet($name) { return $this->_array[$name]; } public function offsetSet($name,$value) { $this->_array[$name] = $value; } public function offsetUnset($name) { unset($this->_array[$name]); } public function offsetExists($name) { return isset($this->_array[$name]); } } $test = new test(); $test['foo'] = 'bar'; $test['baz'] = array('test','validator'); echo $test['baz'][1]; unset($test['baz']); var_dump($test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IssHV
function name:  (null)
number of ops:  16
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'test'
   17     1        NEW                                              $1      'test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   18     4        ASSIGN_DIM                                               !0, 'foo'
          5        OP_DATA                                                  'bar'
   19     6        ASSIGN_DIM                                               !0, 'baz'
          7        OP_DATA                                                  <array>
   20     8        FETCH_DIM_R                                      ~6      !0, 'baz'
          9        FETCH_DIM_R                                      ~7      ~6, 1
         10        ECHO                                                     ~7
   21    11        UNSET_DIM                                                !0, 'baz'
   22    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Class test:
Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IssHV
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_OBJ_R                                      ~1      '_array'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
    6     4*     > RETURN                                                   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/IssHV
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        FETCH_OBJ_W                                      $2      '_array'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
    9     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/IssHV
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        FETCH_OBJ_UNSET                                  $1      '_array'
          2        UNSET_DIM                                                $1, !0
   12     3      > RETURN                                                   null

End of function offsetunset

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

End of function offsetexists

End of class test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.95 ms | 1400 KiB | 15 Q