3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = new stdClass; $obj->{'123'} = '456'; // defined property but unusable as obj->property; see below. print_r($obj); echo 'Via {\'123\'}: ' . $obj->{'123'},"\n"; // echo $obj->123; // Parse error: ...unexpected '123' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' $obj->{'a123'} = $obj->{'123'}; print_r($obj); echo 'Via Property a123: ' . $obj->a123,"\n"; // making a hash out of property a $obj->a["123"] = $obj->{'123'}; $obj->a["a123"] = $obj->{'a123'}; var_dump($obj); echo 'Via Property "a" and hashkey "123": ' . $obj->a["123"],"\n"; // contrast: $obj = (object)array('123' => '456'); // property 123 is invalid print_r($obj); echo $obj->{'123'},"\n"; // so "Undefined property: stdClass::$123"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KMKvE
function name:  (null)
number of ops:  47
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $1      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
    3     3        ASSIGN_OBJ                                               !0, '123'
          4        OP_DATA                                                  '456'
    4     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
    5     8        FETCH_OBJ_R                                      ~6      !0, '123'
          9        CONCAT                                           ~7      'Via+%7B%27123%27%7D%3A+', ~6
         10        ECHO                                                     ~7
         11        ECHO                                                     '%0A'
    8    12        FETCH_OBJ_R                                      ~9      !0, '123'
         13        ASSIGN_OBJ                                               !0, 'a123'
         14        OP_DATA                                                  ~9
    9    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                                 
   10    18        FETCH_OBJ_R                                      ~11     !0, 'a123'
         19        CONCAT                                           ~12     'Via+Property+a123%3A+', ~11
         20        ECHO                                                     ~12
         21        ECHO                                                     '%0A'
   13    22        FETCH_OBJ_R                                      ~15     !0, '123'
         23        FETCH_OBJ_W                                      $13     !0, 'a'
         24        ASSIGN_DIM                                               $13, 123
         25        OP_DATA                                                  ~15
   14    26        FETCH_OBJ_R                                      ~18     !0, 'a123'
         27        FETCH_OBJ_W                                      $16     !0, 'a'
         28        ASSIGN_DIM                                               $16, 'a123'
         29        OP_DATA                                                  ~18
   15    30        INIT_FCALL                                               'var_dump'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                                 
   16    33        FETCH_OBJ_R                                      ~20     !0, 'a'
         34        FETCH_DIM_R                                      ~21     ~20, 123
         35        CONCAT                                           ~22     'Via+Property+%22a%22+and+hashkey+%22123%22%3A+', ~21
         36        ECHO                                                     ~22
         37        ECHO                                                     '%0A'
   19    38        CAST                                          8  ~23     <array>
         39        ASSIGN                                                   !0, ~23
   20    40        INIT_FCALL                                               'print_r'
         41        SEND_VAR                                                 !0
         42        DO_ICALL                                                 
   21    43        FETCH_OBJ_R                                      ~26     !0, '123'
         44        ECHO                                                     ~26
         45        ECHO                                                     '%0A'
         46      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.22 ms | 1400 KiB | 17 Q