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]; echo $array['1']; //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/a0H8t
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'
    6     5        CAST                                          7  ~8      !0
          6        ASSIGN                                                   !1, ~8
    7     7        ASSIGN                                                   !2, '1'
    8     8        FETCH_DIM_R                                      ~11     !1, !2
          9        ECHO                                                     ~11
    9    10        FETCH_DIM_R                                      ~12     !1, 1
         11        ECHO                                                     ~12
   19    12        ASSIGN                                                   !3, '1'
   20    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:
145.82 ms | 1394 KiB | 13 Q