3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = "unchecked"; $a = array(1, 2, 3, "is_ref" => &$x); foreach ($a as $k => $v) { if ($k !== "is_ref") { /* CODE FOR TESTING HERE */ // This will cause a copy: //$a[$k] = null; //$v += 1; //$a[$k] = $v; // This won't: //var_dump($a); } else if (isset($x)) { $x = "was not copied"; unset($x); $tmp = $a; $tmp["is_ref"] = "WAS COPIED!!!"; unset($tmp); echo "######### \$a ".$a["is_ref"]."\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 25
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/ea8i7
function name:  (null)
number of ops:  27
compiled vars:  !0 = $x, !1 = $a, !2 = $v, !3 = $k, !4 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'unchecked'
    4     1        INIT_ARRAY                                       ~6      1
          2        ADD_ARRAY_ELEMENT                                ~6      2
          3        ADD_ARRAY_ELEMENT                                ~6      3
          4        ADD_ARRAY_ELEMENT                                ~6      !0, 'is_ref'
          5        ASSIGN                                                   !1, ~6
    5     6      > FE_RESET_R                                       $8      !1, ->25
          7    > > FE_FETCH_R                                       ~9      $8, !2, ->25
          8    >   ASSIGN                                                   !3, ~9
    6     9        IS_NOT_IDENTICAL                                         !3, 'is_ref'
         10      > JMPZ                                                     ~11, ->12
         11    > > JMP                                                      ->24
   17    12    >   ISSET_ISEMPTY_CV                                         !0
         13      > JMPZ                                                     ~12, ->24
   18    14    >   ASSIGN                                                   !0, 'was+not+copied'
   19    15        UNSET_CV                                                 !0
   20    16        ASSIGN                                                   !4, !1
   21    17        ASSIGN_DIM                                               !4, 'is_ref'
         18        OP_DATA                                                  'WAS+COPIED%21%21%21'
   22    19        UNSET_CV                                                 !4
   23    20        FETCH_DIM_R                                      ~16     !1, 'is_ref'
         21        CONCAT                                           ~17     '%23%23%23%23%23%23%23%23%23+%24a+', ~16
         22        CONCAT                                           ~18     ~17, '%0A'
         23        ECHO                                                     ~18
    5    24    > > JMP                                                      ->7
         25    >   FE_FREE                                                  $8
   25    26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.01 ms | 1395 KiB | 13 Q