3v4l.org

run code in 300+ PHP versions simultaneously
<?php function new_closure_gen() { return function() { static $foo = 0; //return array(++$foo); yield ++$foo; }; } $closure1 = new_closure_gen(); $closure2 = new_closure_gen(); $gen1 = $closure1(); $gen2 = $closure1(); $gen3 = $closure2(); foreach (array($gen1, $gen2, $gen3) as $gen) { foreach ($gen as $val) { print "$val\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 28
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 26
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/EV5o7
function name:  (null)
number of ops:  30
compiled vars:  !0 = $closure1, !1 = $closure2, !2 = $gen1, !3 = $gen2, !4 = $gen3, !5 = $gen, !6 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'new_closure_gen'
          1        DO_FCALL                                      0  $7      
          2        ASSIGN                                                   !0, $7
   12     3        INIT_FCALL                                               'new_closure_gen'
          4        DO_FCALL                                      0  $9      
          5        ASSIGN                                                   !1, $9
   14     6        INIT_DYNAMIC_CALL                                        !0
          7        DO_FCALL                                      0  $11     
          8        ASSIGN                                                   !2, $11
   15     9        INIT_DYNAMIC_CALL                                        !0
         10        DO_FCALL                                      0  $13     
         11        ASSIGN                                                   !3, $13
   16    12        INIT_DYNAMIC_CALL                                        !1
         13        DO_FCALL                                      0  $15     
         14        ASSIGN                                                   !4, $15
   18    15        INIT_ARRAY                                       ~17     !2
         16        ADD_ARRAY_ELEMENT                                ~17     !3
         17        ADD_ARRAY_ELEMENT                                ~17     !4
         18      > FE_RESET_R                                       $18     ~17, ->28
         19    > > FE_FETCH_R                                               $18, !5, ->28
   19    20    > > FE_RESET_R                                       $19     !5, ->26
         21    > > FE_FETCH_R                                               $19, !6, ->26
   20    22    >   NOP                                                      
         23        FAST_CONCAT                                      ~20     !6, '%0A'
         24        ECHO                                                     ~20
   19    25      > JMP                                                      ->21
         26    >   FE_FREE                                                  $19
   18    27      > JMP                                                      ->19
         28    >   FE_FREE                                                  $18
   22    29      > RETURN                                                   1

Function new_closure_gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EV5o7
function name:  new_closure_gen
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEV5o7%3A4%240'
    8     1      > RETURN                                                   ~0
    9     2*     > RETURN                                                   null

End of function new_closure_gen

Function %00%7Bclosure%7D%2Fin%2FEV5o7%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/EV5o7
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   GENERATOR_CREATE                                         
    5     1        BIND_STATIC                                              !0
    7     2        PRE_INC                                          ~1      !0
          3        YIELD                                                    ~1
    8     4      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FEV5o7%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.86 ms | 1402 KiB | 15 Q