3v4l.org

run code in 300+ PHP versions simultaneously
<?php function yield_range( $start, $end ){ while( $start <= $end ){ $ret = yield $start; $start++; echo "yield receive : ".$ret.PHP_EOL; } } $generator = yield_range( 1, 10 ); foreach( $generator as $item ){ $generator->send( $generator->current() * 10 ); echo "=====\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/lvAuH
function name:  (null)
number of ops:  17
compiled vars:  !0 = $generator, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'yield_range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 10
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
   10     5      > FE_RESET_R                                       $4      !0, ->15
          6    > > FE_FETCH_R                                               $4, !1, ->15
   11     7    >   INIT_METHOD_CALL                                         !0, 'send'
          8        INIT_METHOD_CALL                                         !0, 'current'
          9        DO_FCALL                                      0  $5      
         10        MUL                                              ~6      $5, 10
         11        SEND_VAL_EX                                              ~6
         12        DO_FCALL                                      0          
   12    13        ECHO                                                     '%3D%3D%3D%3D%3D%0A'
   10    14      > JMP                                                      ->6
         15    >   FE_FREE                                                  $4
   13    16      > RETURN                                                   1

Function yield_range:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 4
Branch analysis from position: 12
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 4
Branch analysis from position: 12
Branch analysis from position: 4
filename:       /in/lvAuH
function name:  yield_range
number of ops:  13
compiled vars:  !0 = $start, !1 = $end, !2 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        GENERATOR_CREATE                                         
    3     3      > JMP                                                      ->10
    4     4    >   YIELD                                            $3      !0
          5        ASSIGN                                                   !2, $3
    5     6        PRE_INC                                                  !0
    6     7        CONCAT                                           ~6      'yield+receive+%3A+', !2
          8        CONCAT                                           ~7      ~6, '%0A'
          9        ECHO                                                     ~7
    3    10    >   IS_SMALLER_OR_EQUAL                                      !0, !1
         11      > JMPNZ                                                    ~8, ->4
    8    12    > > GENERATOR_RETURN                                         

End of function yield_range

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.26 ms | 1015 KiB | 14 Q