3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doesNotMatter = ['a' => ['id' => 1], 'b' => ['id' => 2]]; $copy1 = $doesNotMatter; $reference = &$doesNotMatter['a']; $copy2 = $doesNotMatter; // Not a reference! var_dump($doesNotMatter); $copy1['a'] = null; $copy2['b'] = null; var_dump($doesNotMatter); $copy2['a'] = null; $copy2['b'] = null; // Intuitively, this should be a copy of $doesNotMatter and shouldn't affect it at all, but because a // reference exists to $doesNotMatter['a'] when $copy2 is created, that key is copied as a reference. // Basically, when a reference is created, PHP treats both the reference and the original as references, // and this affects object properties and array keys in unintuitive ways. var_dump($doesNotMatter);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3RncH
function name:  (null)
number of ops:  23
compiled vars:  !0 = $doesNotMatter, !1 = $copy1, !2 = $reference, !3 = $copy2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, !0
    5     2        FETCH_DIM_W                                      $6      !0, 'a'
          3        ASSIGN_REF                                               !2, $6
    6     4        ASSIGN                                                   !3, !0
    8     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
    9     8        ASSIGN_DIM                                               !1, 'a'
          9        OP_DATA                                                  null
   10    10        ASSIGN_DIM                                               !3, 'b'
         11        OP_DATA                                                  null
   11    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
   12    15        ASSIGN_DIM                                               !3, 'a'
         16        OP_DATA                                                  null
   13    17        ASSIGN_DIM                                               !3, 'b'
         18        OP_DATA                                                  null
   18    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.19 ms | 1010 KiB | 14 Q