3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Article implements ArrayAccess { public $title; function __construct($title) { $this->title = $title; } function offsetSet($key, $value){ $this->{$key} = &$value; } function offsetGet($key){ return $this->{$key}; } function offsetUnset($key){ unset($this->{$key}); } function offsetExists($offset) { return array_key_exists($offset,get_object_vars($this)); } } // Create the object $A = new Article('SPL Rocks'); // Change the title using array syntax using reference $str = 'SPL _really_ rocks'; $A['title'] =&$str; // Check what it looks like again print_r($A);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/upViG
function name:  (null)
number of ops:  12
compiled vars:  !0 = $A, !1 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'article'
   23     1        NEW                                                  $2      'Article'
          2        SEND_VAL_EX                                                  'SPL+Rocks'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $2
   26     5        ASSIGN                                                       !1, 'SPL+_really_+rocks'
   27     6        FETCH_DIM_W                                          $6      !0, 'title'
          7        ASSIGN_REF                                                   $6, !1
   30     8        INIT_FCALL                                                   'print_r'
          9        SEND_VAR                                                     !0
         10        DO_ICALL                                                     
         11      > RETURN                                                       1

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

End of function __construct

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/upViG
function name:  offsetSet
number of ops:  5
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    9     2        ASSIGN_OBJ_REF                                               !0
          3        OP_DATA                                                      !1
   10     4      > RETURN                                                       null

End of function offsetset

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/upViG
function name:  offsetGet
number of ops:  4
compiled vars:  !0 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
   12     1        FETCH_OBJ_R                                          ~1      !0
          2      > RETURN                                                       ~1
   13     3*     > RETURN                                                       null

End of function offsetget

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/upViG
function name:  offsetUnset
number of ops:  3
compiled vars:  !0 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   15     1        UNSET_OBJ                                                    !0
   16     2      > 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/upViG
function name:  offsetExists
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV                                                 !0      
   18     1        INIT_FCALL                                                   'get_object_vars'
          2        FETCH_THIS                                           ~1      
          3        SEND_VAL                                                     ~1
          4        DO_ICALL                                             $2      
          5        ARRAY_KEY_EXISTS                                     ~3      !0, $2
          6      > RETURN                                                       ~3
   19     7*     > RETURN                                                       null

End of function offsetexists

End of class Article.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.51 ms | 3039 KiB | 15 Q