3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayClass implements ArrayAccess { private $container = []; public function __construct(array $array) { $this->container = $array; } 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 $this->offsetExists($offset) ? $this->container[$offset] : false; } } $_POST['aa'] = "dd"; $_POST['bb'] = "xd"; $post = new ArrayClass($_POST); print_r( [ $post['aa'], $post['bb'], $post['cc'], $post ] );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DsX47
function name:  (null)
number of ops:  24
compiled vars:  !0 = $post
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'arrayclass'
   32     1        FETCH_W                      global              $1      '_POST'
          2        ASSIGN_DIM                                               $1, 'aa'
          3        OP_DATA                                                  'dd'
   33     4        FETCH_W                      global              $3      '_POST'
          5        ASSIGN_DIM                                               $3, 'bb'
          6        OP_DATA                                                  'xd'
   35     7        NEW                                              $5      'ArrayClass'
          8        CHECK_FUNC_ARG                                           
          9        FETCH_FUNC_ARG               global              $6      '_POST'
         10        SEND_FUNC_ARG                                            $6
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !0, $5
   37    13        INIT_FCALL                                               'print_r'
   39    14        FETCH_DIM_R                                      ~9      !0, 'aa'
         15        INIT_ARRAY                                       ~10     ~9
   40    16        FETCH_DIM_R                                      ~11     !0, 'bb'
         17        ADD_ARRAY_ELEMENT                                ~10     ~11
   41    18        FETCH_DIM_R                                      ~12     !0, 'cc'
         19        ADD_ARRAY_ELEMENT                                ~10     ~12
   42    20        ADD_ARRAY_ELEMENT                                ~10     !0
         21        SEND_VAL                                                 ~10
         22        DO_ICALL                                                 
   44    23      > RETURN                                                   1

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

End of function offsetunset

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

End of function offsetget

End of class ArrayClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
127.08 ms | 1405 KiB | 15 Q