3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(3, 4); var_dump($arr); $ref =& $arr[0] ; // this statement causes the weird behaviour. Without it all is ok var_dump($arr); // as expected var_dump(doSomethingTo($arr)); // as expected var_dump($arr); // WHAT JUST HAPPENED? function doSomethingTo($arr) { // $arr BY VALUE foreach($arr as $k => $v) $arr[$k]=$v+1 ; return $arr ; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DXWNd
function name:  (null)
number of ops:  19
compiled vars:  !0 = $arr, !1 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
    5     4        FETCH_DIM_W                                      $4      !0, 0
          5        ASSIGN_REF                                               !1, $4
    7     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
    8     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL_BY_NAME                                       'doSomethingTo'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                                 
    9    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                                 
   16    18      > RETURN                                                   1

Function dosomethingto:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 8
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/DXWNd
function name:  doSomethingTo
number of ops:  11
compiled vars:  !0 = $arr, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1      > FE_RESET_R                                       $3      !0, ->8
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->8
          3    >   ASSIGN                                                   !2, ~4
   14     4        ADD                                              ~7      !1, 1
          5        ASSIGN_DIM                                               !0, !2
          6        OP_DATA                                                  ~7
   13     7      > JMP                                                      ->2
          8    >   FE_FREE                                                  $3
   15     9      > RETURN                                                   !0
   16    10*     > RETURN                                                   null

End of function dosomethingto

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.36 ms | 998 KiB | 14 Q