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) { if ($offset === 0 || $offset == 'uid') { 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/VLaJ0
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'
   31     1        NEW                                              $1      'stdClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   32     4        ASSIGN_OBJ                                               !0, 'uid'
          5        OP_DATA                                                  '1234'
   33     6        FETCH_OBJ_R                                      ~5      !0, 'uid'
          7        ECHO                                                     ~5
   34     8        ECHO                                                     '%0A'
   35     9        FETCH_OBJ_R                                      ~6      !0, 'uid'
         10        FETCH_DIM_R                                      ~7      ~6, 0
         11        ECHO                                                     ~7
   36    12        ECHO                                                     '%0A'
   37    13        ASSIGN                                                   !0, <array>
   38    14        ASSIGN_DIM                                               !0, 'uid'
         15        OP_DATA                                                  '1234'
   39    16        FETCH_DIM_R                                      ~10     !0, 'uid'
         17        ECHO                                                     ~10
   40    18        ECHO                                                     '%0A'
   41    19        FETCH_DIM_R                                      ~11     !0, 'uid'
         20        FETCH_DIM_R                                      ~12     ~11, 0
         21        ECHO                                                     ~12
   42    22        ECHO                                                     '%0ANew+Uid+Class%0A'
   43    23        NEW                                              $14     'Uid'
         24        SEND_VAL_EX                                              '1234'
         25        DO_FCALL                                      0          
         26        ASSIGN_DIM                                               !0, 'uid'
         27        OP_DATA                                                  $14
   44    28        FETCH_DIM_R                                      ~16     !0, 'uid'
         29        ECHO                                                     ~16
   45    30        ECHO                                                     '%0A'
   46    31        FETCH_DIM_R                                      ~17     !0, 'uid'
         32        FETCH_DIM_R                                      ~18     ~17, 0
         33        ECHO                                                     ~18
   47    34        ECHO                                                     '%0A'
   48    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/VLaJ0
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/VLaJ0
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/VLaJ0
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
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/VLaJ0
function name:  offsetGet
number of ops:  9
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        IS_IDENTICAL                                     ~1      !0, 0
          2      > JMPNZ_EX                                         ~1      ~1, ->5
          3    >   IS_EQUAL                                         ~2      !0, 'uid'
          4        BOOL                                             ~1      ~2
          5    > > JMPZ                                                     ~1, ->8
   21     6    >   FETCH_OBJ_R                                      ~3      'uid'
          7      > RETURN                                                   ~3
   23     8    > > 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/VLaJ0
function name:  offsetSet
number of ops:  3
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     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/VLaJ0
function name:  offsetUnset
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     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:
160.79 ms | 1403 KiB | 13 Q