3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(1, 1); $a = &$arr[0]; $a++; //'$a' and '$arr[0]' point to the same reference. echo '$arr:' . "\n"; var_dump($arr); echo '$a:' . "\n"; var_dump($a); echo PHP_EOL . PHP_EOL; $arr2 = $arr; $arr2[0]++; $arr2[1]++; //Even though you didn't assigned '$arr' to '$arr2' by reference, the first element keeps the reference to the original value. Now '$arr[0]', '$a' and '$arr2[0]' point all to the same reference. //But the second element won't change for the '$arr' array echo '$arr:' . "\n"; var_dump($arr); echo '$arr2:' . "\n"; var_dump($arr2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/la5El
function name:  (null)
number of ops:  27
compiled vars:  !0 = $arr, !1 = $a, !2 = $arr2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        FETCH_DIM_W                                      $4      !0, 0
          2        ASSIGN_REF                                               !1, $4
    6     3        PRE_INC                                                  !1
    9     4        ECHO                                                     '%24arr%3A%0A'
   10     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   11     8        ECHO                                                     '%24a%3A%0A'
   12     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
   15    12        ECHO                                                     '%0A%0A'
   18    13        ASSIGN                                                   !2, !0
   19    14        FETCH_DIM_RW                                     $10     !2, 0
         15        PRE_INC                                                  $10
   20    16        FETCH_DIM_RW                                     $12     !2, 1
         17        PRE_INC                                                  $12
   24    18        ECHO                                                     '%24arr%3A%0A'
   25    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                                 
   26    22        ECHO                                                     '%24arr2%3A%0A'
   27    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.58 ms | 1395 KiB | 15 Q