3v4l.org

run code in 300+ PHP versions simultaneously
<?php class obj implements arrayaccess { private $container = array(); public function __construct() { $this->container = array( "one" => 1, "two" => 2, "three" => 3, ); } public function offsetSet($offset, $value) { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } public function offsetExists($offset) { return isset($this->container[$offset]); } public function offsetUnset($offset) { unset($this->container[$offset]); } public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } $obj = new obj; var_dump(isset($obj["two"])); var_dump($obj["two"]); unset($obj["two"]); var_dump(isset($obj["two"])); $obj["two"] = "A value"; var_dump($obj["two"]); $obj[] = 'Append 1'; $obj[] = 'Append 2'; $obj[] = 'Append 3'; print_r($obj);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E2pCY
function name:  (null)
number of ops:  33
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'obj'
   31     1        NEW                                              $1      'obj'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   33     4        INIT_FCALL                                               'var_dump'
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      !0, 'two'
          6        SEND_VAL                                                 ~4
          7        DO_ICALL                                                 
   34     8        INIT_FCALL                                               'var_dump'
          9        FETCH_DIM_R                                      ~6      !0, 'two'
         10        SEND_VAL                                                 ~6
         11        DO_ICALL                                                 
   35    12        UNSET_DIM                                                !0, 'two'
   36    13        INIT_FCALL                                               'var_dump'
         14        ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !0, 'two'
         15        SEND_VAL                                                 ~8
         16        DO_ICALL                                                 
   37    17        ASSIGN_DIM                                               !0, 'two'
         18        OP_DATA                                                  'A+value'
   38    19        INIT_FCALL                                               'var_dump'
         20        FETCH_DIM_R                                      ~11     !0, 'two'
         21        SEND_VAL                                                 ~11
         22        DO_ICALL                                                 
   39    23        ASSIGN_DIM                                               !0
         24        OP_DATA                                                  'Append+1'
   40    25        ASSIGN_DIM                                               !0
         26        OP_DATA                                                  'Append+2'
   41    27        ASSIGN_DIM                                               !0
         28        OP_DATA                                                  'Append+3'
   42    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Class obj:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E2pCY
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN_OBJ                                               'container'
    8     1        OP_DATA                                                  <array>
   12     2      > RETURN                                                   null

End of function __construct

Function offsetset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E2pCY
function name:  offsetSet
number of ops:  12
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        TYPE_CHECK                                    2          !0
          3      > JMPZ                                                     ~2, ->8
   15     4    >   FETCH_OBJ_W                                      $3      'container'
          5        ASSIGN_DIM                                               $3
          6        OP_DATA                                                  !1
          7      > JMP                                                      ->11
   17     8    >   FETCH_OBJ_W                                      $5      'container'
          9        ASSIGN_DIM                                               $5, !0
         10        OP_DATA                                                  !1
   19    11    > > 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/E2pCY
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        FETCH_OBJ_IS                                     ~1      'container'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
   22     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/E2pCY
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        FETCH_OBJ_UNSET                                  $1      'container'
          2        UNSET_DIM                                                $1, !0
   25     3      > RETURN                                                   null

End of function offsetunset

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E2pCY
function name:  offsetGet
number of ops:  11
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        FETCH_OBJ_IS                                     ~1      'container'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_OBJ_R                                      ~3      'container'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      null
          9    > > RETURN                                                   ~5
   28    10*     > RETURN                                                   null

End of function offsetget

End of class obj.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.58 ms | 1404 KiB | 17 Q