3v4l.org

run code in 300+ PHP versions simultaneously
<?php function &foo() { $x = array(1,2,3); $y =& $x; yield $y; yield $x; echo "Gen: "; var_dump($x); echo "Gen: "; var_dump($y); $x[] = 100; echo "Gen: "; var_dump($x); echo "Gen: "; var_dump($y); yield 'done'; } $gen = foo(); $a =& $gen->current(); $gen->next(); $b =& $gen->current(); var_dump($a); var_dump($b); $b[] = 42; var_dump($a); var_dump($b); $gen->next();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MgdnW
function name:  (null)
number of ops:  28
compiled vars:  !0 = $gen, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'foo'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   17     3        INIT_METHOD_CALL                                         !0, 'current'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN_REF                                               !1, $5
   18     6        INIT_METHOD_CALL                                         !0, 'next'
          7        DO_FCALL                                      0          
   19     8        INIT_METHOD_CALL                                         !0, 'current'
          9        DO_FCALL                                      0  $8      
         10        ASSIGN_REF                                               !2, $8
   20    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   21    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
   22    17        ASSIGN_DIM                                               !2
         18        OP_DATA                                                  42
   23    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
   24    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                                 
   25    25        INIT_METHOD_CALL                                         !0, 'next'
         26        DO_FCALL                                      0          
         27      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/MgdnW
function name:  foo
number of ops:  25
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        ASSIGN                                                   !0, <array>
    5     2        ASSIGN_REF                                               !1, !0
    6     3        YIELD                                                    !1
    7     4        YIELD                                                    !0
    8     5        ECHO                                                     'Gen%3A+'
          6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
    9     9        ECHO                                                     'Gen%3A+'
         10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
   10    13        ASSIGN_DIM                                               !0
         14        OP_DATA                                                  100
   11    15        ECHO                                                     'Gen%3A+'
         16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
   12    19        ECHO                                                     'Gen%3A+'
         20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                                 
   13    23        YIELD                                                    'done'
   14    24      > GENERATOR_RETURN                                         

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.01 ms | 1403 KiB | 16 Q