3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object = new stdClass(); $object->{'1'} = 'one'; echo $object->{'1'}; $array = (array) $object; $test = '1'; echo $array[$test]; //var_dump($array); /* produces array(1) { ["1"]=> string(3) "one" } */ //none of the following will work $key = '1'; echo $array[1], $array['1'], $array["1"], $array[(string)1], $array[$key];
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fD3bF
function name:  (null)
number of ops:  25
compiled vars:  !0 = $object, !1 = $array, !2 = $test, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $4      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
    4     3        ASSIGN_OBJ                                               !0, '1'
          4        OP_DATA                                                  'one'
    5     5        FETCH_OBJ_R                                      ~8      !0, '1'
          6        ECHO                                                     ~8
    6     7        CAST                                          7  ~9      !0
          8        ASSIGN                                                   !1, ~9
    7     9        ASSIGN                                                   !2, '1'
    8    10        FETCH_DIM_R                                      ~12     !1, !2
         11        ECHO                                                     ~12
   18    12        ASSIGN                                                   !3, '1'
   19    13        FETCH_DIM_R                                      ~14     !1, 1
         14        ECHO                                                     ~14
         15        FETCH_DIM_R                                      ~15     !1, 1
         16        ECHO                                                     ~15
         17        FETCH_DIM_R                                      ~16     !1, 1
         18        ECHO                                                     ~16
         19        CAST                                          6  ~17     1
         20        FETCH_DIM_R                                      ~18     !1, ~17
         21        ECHO                                                     ~18
         22        FETCH_DIM_R                                      ~19     !1, !3
         23        ECHO                                                     ~19
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.36 ms | 1385 KiB | 13 Q