3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $obj = new stdClass(); $obj->bar = "xyz"; $data = array("foo" => "bar"); $key = "foo"; // echo $obj->${data[$key]}; syntax error echo $obj->{$data[$key]}; $member = $data[$key]; echo $obj->${member}; echo $obj->{$member}; echo ${data[$key]}; echo "${data[$key]}"; // of course, this works echo "\n{${'data'}[$key]}\n"; echo "{$data[$key]}";
based on d9khY
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fCvQh
function name:  (null)
number of ops:  34
compiled vars:  !0 = $obj, !1 = $data, !2 = $key, !3 = $member
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NEW                                              $4      :-5
         1        DO_FCALL                                      0          
         2        ASSIGN                                                   !0, $4
   4     3        ASSIGN_OBJ                                               !0, 'bar'
         4        OP_DATA                                                  'xyz'
   5     5        ASSIGN                                                   !1, <array>
   6     6        ASSIGN                                                   !2, 'foo'
   8     7        FETCH_DIM_R                                      $10     !1, !2
         8        FETCH_OBJ_R                                      $11     !0, $10
         9        ECHO                                                     $11
   9    10        FETCH_DIM_R                                      $12     !1, !2
        11        ASSIGN                                                   !3, $12
  10    12        FETCH_CONSTANT                                   ~14     'member'
        13        FETCH_R                      local               $15     ~14
        14        FETCH_OBJ_R                                      $16     !0, $15
        15        ECHO                                                     $16
  11    16        FETCH_OBJ_R                                      $17     !0, !3
        17        ECHO                                                     $17
  13    18        FETCH_CONSTANT                                   ~18     'data'
        19        FETCH_DIM_R                                      $19     ~18, !2
        20        FETCH_R                      local               $20     $19
        21        ECHO                                                     $20
  14    22        FETCH_DIM_R                                      $21     !1, !2
        23        CAST                                          6  ~22     $21
        24        ECHO                                                     ~22
  15    25        FETCH_DIM_R                                      $23     !1, !2
        26        ROPE_INIT                                     3  ~25     '%0A'
        27        ROPE_ADD                                      1  ~25     ~25, $23
        28        ROPE_END                                      2  ~24     ~25, '%0A'
        29        ECHO                                                     ~24
  16    30        FETCH_DIM_R                                      $27     !1, !2
        31        CAST                                          6  ~28     $27
        32        ECHO                                                     ~28
        33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 7.3.0