3v4l.org

run code in 300+ PHP versions simultaneously
<?php function &foo() { $x = array(1,2,3); yield $x; echo "Gen: "; var_dump($x); $x[] = 99; return $x; } $rets = array(); $gen = foo(); foreach ($gen as &$val) { var_dump($val); $val[] = 42; $rets[] =& $val; } $rv =& $gen->getReturn(); var_dump($rv); $rets[0][] = 100; var_dump($rv); $rv[] = 200; var_dump($rv); var_dump($gen->getReturn()); var_dump($rets);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 126) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/h2fdo
function name:  (null)
number of ops:  41
compiled vars:  !0 = $rets, !1 = $gen, !2 = $val, !3 = $rv
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'foo'
          2        DO_FCALL                                      0  $5      
          3        ASSIGN                                                   !1, $5
   13     4      > FE_RESET_RW                                      $7      !1, ->14
          5    > > FE_FETCH_RW                                              $7, !2, ->14
   14     6    >   INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                                 
   15     9        ASSIGN_DIM                                               !2
         10        OP_DATA                                                  42
   16    11        FETCH_DIM_W                                      $10     !0
         12        ASSIGN_REF                                               $10, !2
   13    13      > JMP                                                      ->5
         14    >   FE_FREE                                                  $7
   18    15        INIT_METHOD_CALL                                         !1, 'getReturn'
         16        DO_FCALL                                      0  $12     
         17        ASSIGN_REF                                               !3, $12
   19    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !3
         20        DO_ICALL                                                 
   20    21        FETCH_DIM_W                                      $15     !0, 0
         22        ASSIGN_DIM                                               $15
         23        OP_DATA                                                  100
   21    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                                 
   22    27        ASSIGN_DIM                                               !3
         28        OP_DATA                                                  200
   23    29        INIT_FCALL                                               'var_dump'
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                                 
   24    32        INIT_FCALL                                               'var_dump'
         33        INIT_METHOD_CALL                                         !1, 'getReturn'
         34        DO_FCALL                                      0  $20     
         35        SEND_VAR                                                 $20
         36        DO_ICALL                                                 
   25    37        INIT_FCALL                                               'var_dump'
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/h2fdo
function name:  foo
number of ops:  11
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        ASSIGN                                                   !0, <array>
    5     2        YIELD                                                    !0
    6     3        ECHO                                                     'Gen%3A+'
          4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
    7     7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  99
    8     9      > GENERATOR_RETURN                                         
    9    10*     > GENERATOR_RETURN                                         

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.17 ms | 1403 KiB | 16 Q