3v4l.org

run code in 300+ PHP versions simultaneously
<?php function nums() { for ($i = 0; $i < 5; ++$i) { //get a value from the caller $cmd = (yield $i); if($cmd == 'stop') return;//exit the function } } $gen = nums(); foreach($gen as $v) { if($v == 3)//we are satisfied $gen->send('stop'); echo "{$v}\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/9bBGH
function name:  (null)
number of ops:  16
compiled vars:  !0 = $gen, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'nums'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   14     3      > FE_RESET_R                                       $4      !0, ->14
          4    > > FE_FETCH_R                                               $4, !1, ->14
   16     5    >   IS_EQUAL                                                 !1, 3
          6      > JMPZ                                                     ~5, ->10
   17     7    >   INIT_METHOD_CALL                                         !0, 'send'
          8        SEND_VAL_EX                                              'stop'
          9        DO_FCALL                                      0          
   19    10    >   NOP                                                      
         11        FAST_CONCAT                                      ~7      !1, '%0A'
         12        ECHO                                                     ~7
   14    13      > JMP                                                      ->4
         14    >   FE_FREE                                                  $4
   20    15      > RETURN                                                   1

Function nums:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/9bBGH
function name:  nums
number of ops:  12
compiled vars:  !0 = $i, !1 = $cmd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        ASSIGN                                                   !0, 0
          2      > JMP                                                      ->9
    6     3    >   YIELD                                            $3      !0
          4        ASSIGN                                                   !1, $3
    8     5        IS_EQUAL                                                 !1, 'stop'
          6      > JMPZ                                                     ~5, ->8
    9     7    > > GENERATOR_RETURN                                         
    4     8    >   PRE_INC                                                  !0
          9    >   IS_SMALLER                                               !0, 5
         10      > JMPNZ                                                    ~7, ->3
   11    11    > > GENERATOR_RETURN                                         

End of function nums

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
290.39 ms | 1398 KiB | 15 Q