3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements ArrayAccess { public function offsetGet($offset){ return gettype($offset); } public function offsetSet($offset, $value){} public function offsetUnset($offset){} public function offsetExists($offset){} } $a = array('a', 'b', 'c'); $o = new Test(); $s = '1'; echo $o[1], "\n"; // 'integer' echo $o['1'], "\n"; // 'integer' !? echo $o[1.0], "\n"; // 'double' echo $o[$s], "\n"; // 'string' echo $o[$o], "\n"; // 'object' echo $a[1], "\n"; // 'integer' echo $a['1'], "\n"; // 'integer' echo $a[1.0], "\n"; // 'integer' echo $a[$s], "\n"; // 'integer' echo $a[$o], "\n"; // Warning: Illegal offset type
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0BMYh
function name:  (null)
number of ops:  37
compiled vars:  !0 = $a, !1 = $o, !2 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'test'
   14     1        ASSIGN                                                   !0, <array>
   15     2        NEW                                              $4      'Test'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   16     5        ASSIGN                                                   !2, '1'
   18     6        FETCH_DIM_R                                      ~8      !1, 1
          7        ECHO                                                     ~8
          8        ECHO                                                     '%0A'
   19     9        FETCH_DIM_R                                      ~9      !1, 1
         10        ECHO                                                     ~9
         11        ECHO                                                     '%0A'
   20    12        FETCH_DIM_R                                      ~10     !1, 1
         13        ECHO                                                     ~10
         14        ECHO                                                     '%0A'
   21    15        FETCH_DIM_R                                      ~11     !1, !2
         16        ECHO                                                     ~11
         17        ECHO                                                     '%0A'
   22    18        FETCH_DIM_R                                      ~12     !1, !1
         19        ECHO                                                     ~12
         20        ECHO                                                     '%0A'
   24    21        FETCH_DIM_R                                      ~13     !0, 1
         22        ECHO                                                     ~13
         23        ECHO                                                     '%0A'
   25    24        FETCH_DIM_R                                      ~14     !0, 1
         25        ECHO                                                     ~14
         26        ECHO                                                     '%0A'
   26    27        FETCH_DIM_R                                      ~15     !0, 1
         28        ECHO                                                     ~15
         29        ECHO                                                     '%0A'
   27    30        FETCH_DIM_R                                      ~16     !0, !2
         31        ECHO                                                     ~16
         32        ECHO                                                     '%0A'
   28    33        FETCH_DIM_R                                      ~17     !0, !1
         34        ECHO                                                     ~17
         35        ECHO                                                     '%0A'
         36      > RETURN                                                   1

Class Test:
Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0BMYh
function name:  offsetGet
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        GET_TYPE                                         ~1      !0
          2      > RETURN                                                   ~1
    7     3*     > 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/0BMYh
function name:  offsetSet
number of ops:  3
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     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/0BMYh
function name:  offsetUnset
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1      > 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/0BMYh
function name:  offsetExists
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function offsetexists

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.63 ms | 1399 KiB | 13 Q