3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayObjectChild extends ArrayObject { public function offsetExists($offset) { var_dump('Called: '.__METHOD__); return parent::offsetExists($offset); } public function offsetGet($offset) { var_dump('Called: '.__METHOD__); return parent::offsetGet($offset); } } class ArrayAcessImplementation implements ArrayAccess { private $_array = array(); public function __construct(array $array) { $this->_array = $array; } public function offsetExists($offset) { var_dump('Called: '.__METHOD__); return array_key_exists($offset, $this->_array); } public function offsetGet($offset) { var_dump('Called: '.__METHOD__); return $this->_array[$offset]; } public function offsetSet($offset, $value) {} public function offsetUnset($offset) {} } $array = array('foo' => ''); echo "ArrayObject: empty string is set, but empty:\n"; $object = new ArrayObject($array); var_dump(isset($object['foo']), empty($object['foo'])); echo "ArrayObject extended: empty string is set, but not empty\n"; $object = new ArrayObjectChild($array); var_dump($object['foo'], isset($object['foo']), empty($object['foo'])); echo "ArrayAccess implemented: empty string is set, but empty\n"; $object = new ArrayAcessImplementation($array); var_dump(isset($object['foo']), empty($object['foo']));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/auAaP
function name:  (null)
number of ops:  38
compiled vars:  !0 = $array, !1 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   DECLARE_CLASS                                            'arrayacessimplementation'
   39     1        ASSIGN                                                   !0, <array>
   41     2        ECHO                                                     'ArrayObject%3A+empty+string+is+set%2C+but+empty%3A%0A'
   42     3        NEW                                              $3      'ArrayObject'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $3
   43     7        INIT_FCALL                                               'var_dump'
          8        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !1, 'foo'
          9        SEND_VAL                                                 ~6
         10        ISSET_ISEMPTY_DIM_OBJ                         1  ~7      !1, 'foo'
         11        SEND_VAL                                                 ~7
         12        DO_ICALL                                                 
   45    13        ECHO                                                     'ArrayObject+extended%3A+empty+string+is+set%2C+but+not+empty%0A'
   46    14        NEW                                              $9      'ArrayObjectChild'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !1, $9
   47    18        INIT_FCALL                                               'var_dump'
         19        FETCH_DIM_R                                      ~12     !1, 'foo'
         20        SEND_VAL                                                 ~12
         21        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !1, 'foo'
         22        SEND_VAL                                                 ~13
         23        ISSET_ISEMPTY_DIM_OBJ                         1  ~14     !1, 'foo'
         24        SEND_VAL                                                 ~14
         25        DO_ICALL                                                 
   49    26        ECHO                                                     'ArrayAccess+implemented%3A+empty+string+is+set%2C+but+empty%0A'
   50    27        NEW                                              $16     'ArrayAcessImplementation'
         28        SEND_VAR_EX                                              !0
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !1, $16
   51    31        INIT_FCALL                                               'var_dump'
         32        ISSET_ISEMPTY_DIM_OBJ                         0  ~19     !1, 'foo'
         33        SEND_VAL                                                 ~19
         34        ISSET_ISEMPTY_DIM_OBJ                         1  ~20     !1, 'foo'
         35        SEND_VAL                                                 ~20
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Class ArrayObjectChild:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/auAaP
function name:  offsetExists
number of ops:  9
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'Called%3A+ArrayObjectChild%3A%3AoffsetExists'
          3        DO_ICALL                                                 
    7     4        INIT_STATIC_METHOD_CALL                                  'offsetExists'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
    8     8*     > RETURN                                                   null

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/auAaP
function name:  offsetGet
number of ops:  9
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'Called%3A+ArrayObjectChild%3A%3AoffsetGet'
          3        DO_ICALL                                                 
   12     4        INIT_STATIC_METHOD_CALL                                  'offsetGet'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   13     8*     > RETURN                                                   null

End of function offsetget

End of class ArrayObjectChild.

Class ArrayAcessImplementation:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/auAaP
function name:  __construct
number of ops:  4
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        ASSIGN_OBJ                                               '_array'
          2        OP_DATA                                                  !0
   23     3      > RETURN                                                   null

End of function __construct

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/auAaP
function name:  offsetExists
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'Called%3A+ArrayAcessImplementation%3A%3AoffsetExists'
          3        DO_ICALL                                                 
   27     4        FETCH_OBJ_R                                      ~2      '_array'
          5        ARRAY_KEY_EXISTS                                 ~3      !0, ~2
          6      > RETURN                                                   ~3
   28     7*     > RETURN                                                   null

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/auAaP
function name:  offsetGet
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'Called%3A+ArrayAcessImplementation%3A%3AoffsetGet'
          3        DO_ICALL                                                 
   32     4        FETCH_OBJ_R                                      ~2      '_array'
          5        FETCH_DIM_R                                      ~3      ~2, !0
          6      > RETURN                                                   ~3
   33     7*     > 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/auAaP
function name:  offsetSet
number of ops:  3
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2      > 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/auAaP
function name:  offsetUnset
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function offsetunset

End of class ArrayAcessImplementation.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.63 ms | 1409 KiB | 15 Q