3v4l.org

run code in 300+ PHP versions simultaneously
<?php function nums() { $ary = [24,25,26,27,28,29,30,31,32]; $i = 0; foreach ($ary as $x) { $cmd = (yield $x); // yield expr echo $x; if ($cmd == 'stop') { echo 'Generator stopped.',"\n"; } } echo "Generator is now closed","\n"; return; } $gen = nums(); foreach ($gen as $value) { //echo "$value\n"; if ($value == 26) { // don't let it get to 32 $gen->send('stop'); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 11
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: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/UmttY
function name:  (null)
number of ops:  13
compiled vars:  !0 = $gen, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'nums'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   18     3      > FE_RESET_R                                       $4      !0, ->11
          4    > > FE_FETCH_R                                               $4, !1, ->11
   20     5    >   IS_EQUAL                                                 !1, 26
          6      > JMPZ                                                     ~5, ->10
   21     7    >   INIT_METHOD_CALL                                         !0, 'send'
          8        SEND_VAL_EX                                              'stop'
          9        DO_FCALL                                      0          
   18    10    > > JMP                                                      ->4
         11    >   FE_FREE                                                  $4
   23    12      > RETURN                                                   1

Function nums:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
Branch analysis from position: 13
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 13
filename:       /in/UmttY
function name:  nums
number of ops:  18
compiled vars:  !0 = $ary, !1 = $i, !2 = $x, !3 = $cmd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   GENERATOR_CREATE                                         
    3     1        ASSIGN                                                   !0, <array>
    4     2        ASSIGN                                                   !1, 0
    5     3      > FE_RESET_R                                       $6      !0, ->13
          4    > > FE_FETCH_R                                               $6, !2, ->13
    6     5    >   YIELD                                            $7      !2
          6        ASSIGN                                                   !3, $7
    7     7        ECHO                                                     !2
    8     8        IS_EQUAL                                                 !3, 'stop'
          9      > JMPZ                                                     ~9, ->12
    9    10    >   ECHO                                                     'Generator+stopped.'
         11        ECHO                                                     '%0A'
    5    12    > > JMP                                                      ->4
         13    >   FE_FREE                                                  $6
   12    14        ECHO                                                     'Generator+is+now+closed'
         15        ECHO                                                     '%0A'
   13    16      > GENERATOR_RETURN                                         
   14    17*     > GENERATOR_RETURN                                         

End of function nums

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.11 ms | 1403 KiB | 14 Q