3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Uid implements \ArrayAccess { protected $uid; public function __construct($uid) { $this->uid = $uid; } public function __toString() { return $this->uid; } public function offsetExists($offset) { return $offset === 0; } public function offsetGet($offset) { return $this->uid; } public function offsetSet($offset, $value) {} public function offsetUnset($offset) {} } $data = new stdClass(); $data->uid = '1234'; print $data->uid; print "\n"; print $data->uid[0]; print "\n"; $data = array(); $data['uid'] = '1234'; print $data['uid']; print "\n"; print $data['uid'][0]; print "\nNew Uid Class\n"; $data['uid'] = new Uid('1234'); print $data['uid']; print "\n"; print $data['uid'][0]; print "\n"; print $data['uid'][1];
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vt8X6
function name:  (null)
number of ops:  39
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'uid'
   29     1        NEW                                              $1      'stdClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   30     4        ASSIGN_OBJ                                               !0, 'uid'
          5        OP_DATA                                                  '1234'
   31     6        FETCH_OBJ_R                                      ~5      !0, 'uid'
          7        ECHO                                                     ~5
   32     8        ECHO                                                     '%0A'
   33     9        FETCH_OBJ_R                                      ~6      !0, 'uid'
         10        FETCH_DIM_R                                      ~7      ~6, 0
         11        ECHO                                                     ~7
   34    12        ECHO                                                     '%0A'
   35    13        ASSIGN                                                   !0, <array>
   36    14        ASSIGN_DIM                                               !0, 'uid'
         15        OP_DATA                                                  '1234'
   37    16        FETCH_DIM_R                                      ~10     !0, 'uid'
         17        ECHO                                                     ~10
   38    18        ECHO                                                     '%0A'
   39    19        FETCH_DIM_R                                      ~11     !0, 'uid'
         20        FETCH_DIM_R                                      ~12     ~11, 0
         21        ECHO                                                     ~12
   40    22        ECHO                                                     '%0ANew+Uid+Class%0A'
   41    23        NEW                                              $14     'Uid'
         24        SEND_VAL_EX                                              '1234'
         25        DO_FCALL                                      0          
         26        ASSIGN_DIM                                               !0, 'uid'
         27        OP_DATA                                                  $14
   42    28        FETCH_DIM_R                                      ~16     !0, 'uid'
         29        ECHO                                                     ~16
   43    30        ECHO                                                     '%0A'
   44    31        FETCH_DIM_R                                      ~17     !0, 'uid'
         32        FETCH_DIM_R                                      ~18     ~17, 0
         33        ECHO                                                     ~18
   45    34        ECHO                                                     '%0A'
   46    35        FETCH_DIM_R                                      ~19     !0, 'uid'
         36        FETCH_DIM_R                                      ~20     ~19, 1
         37        ECHO                                                     ~20
         38      > RETURN                                                   1

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

End of function __construct

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vt8X6
function name:  __toString
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_OBJ_R                                      ~0      'uid'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   13     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function __tostring

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vt8X6
function name:  offsetExists
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        IS_IDENTICAL                                     ~1      !0, 0
          2      > RETURN                                                   ~1
   17     3*     > 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/Vt8X6
function name:  offsetGet
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        FETCH_OBJ_R                                      ~1      'uid'
          2      > RETURN                                                   ~1
   21     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/Vt8X6
function name:  offsetSet
number of ops:  3
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     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/Vt8X6
function name:  offsetUnset
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function offsetunset

End of class Uid.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.33 ms | 1399 KiB | 13 Q