3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generate_ints($n){ foreach ( range(0,$n) as $number) { $number = (yield $number); } } $gen = generate_ints(5); // iterable object can be used in foreach foreach ($gen as $g) { // $g == $gen->current() echo $g; if ($gen->current() == 4) { $gen->send("\n999\n"); // injecting a value } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/reELt
function name:  (null)
number of ops:  17
compiled vars:  !0 = $gen, !1 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'generate_ints'
          1        SEND_VAL                                                 5
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   12     4      > FE_RESET_R                                       $4      !0, ->15
          5    > > FE_FETCH_R                                               $4, !1, ->15
   13     6    >   ECHO                                                     !1
   14     7        INIT_METHOD_CALL                                         !0, 'current'
          8        DO_FCALL                                      0  $5      
          9        IS_EQUAL                                                 $5, 4
         10      > JMPZ                                                     ~6, ->14
   15    11    >   INIT_METHOD_CALL                                         !0, 'send'
         12        SEND_VAL_EX                                              '%0A999%0A'
         13        DO_FCALL                                      0          
   12    14    > > JMP                                                      ->5
         15    >   FE_FREE                                                  $4
   18    16      > RETURN                                                   1

Function generate_ints:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 11
filename:       /in/reELt
function name:  generate_ints
number of ops:  13
compiled vars:  !0 = $n, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    3     2        INIT_FCALL                                               'range'
          3        SEND_VAL                                                 0
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6      > FE_RESET_R                                       $3      $2, ->11
          7    > > FE_FETCH_R                                               $3, !1, ->11
    4     8    >   YIELD                                            $4      !1
          9        ASSIGN                                                   !1, $4
    3    10      > JMP                                                      ->7
         11    >   FE_FREE                                                  $3
    7    12      > GENERATOR_RETURN                                         

End of function generate_ints

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.89 ms | 1398 KiB | 16 Q