3v4l.org

run code in 300+ PHP versions simultaneously
<?php function nums() { $ary = [24,25,26,27,28,29,30,31,32]; for($x = 0, $max = count($ary); ($x < $max || $x == 999); $x += 2) { $cmd = (yield $ary[$x]); // yield expr if ($cmd == 999) { var_dump($cmd); $x = 999; } } } $gen = nums(); foreach ($gen as $value) { echo "$value\n"; if ($value == 28) { // don't let it get to 32 $gen->send(999); } }
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 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/vSt3t
function name:  (null)
number of ops:  16
compiled vars:  !0 = $gen, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'nums'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   15     3      > FE_RESET_R                                       $4      !0, ->14
          4    > > FE_FETCH_R                                               $4, !1, ->14
   16     5    >   NOP                                                      
          6        FAST_CONCAT                                      ~5      !1, '%0A'
          7        ECHO                                                     ~5
   17     8        IS_EQUAL                                                 !1, 28
          9      > JMPZ                                                     ~6, ->13
   18    10    >   INIT_METHOD_CALL                                         !0, 'send'
         11        SEND_VAL_EX                                              999
         12        DO_FCALL                                      0          
   15    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 = 16
Branch analysis from position: 16
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 6
Branch analysis from position: 21
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
Branch analysis from position: 20
Branch analysis from position: 15
Branch analysis from position: 20
filename:       /in/vSt3t
function name:  nums
number of ops:  22
compiled vars:  !0 = $ary, !1 = $x, !2 = $max, !3 = $cmd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   GENERATOR_CREATE                                         
    3     1        ASSIGN                                                   !0, <array>
    5     2        ASSIGN                                                   !1, 0
          3        COUNT                                            ~6      !0
          4        ASSIGN                                                   !2, ~6
          5      > JMP                                                      ->16
    6     6    >   FETCH_DIM_R                                      ~8      !0, !1
          7        YIELD                                            $9      ~8
          8        ASSIGN                                                   !3, $9
    7     9        IS_EQUAL                                                 !3, 999
         10      > JMPZ                                                     ~11, ->15
    8    11    >   INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                                 
    9    14        ASSIGN                                                   !1, 999
    5    15    >   ASSIGN_OP                                     1          !1, 2
         16    >   IS_SMALLER                                       ~15     !1, !2
         17      > JMPNZ_EX                                         ~15     ~15, ->20
         18    >   IS_EQUAL                                         ~16     !1, 999
         19        BOOL                                             ~15     ~16
         20    > > JMPNZ                                                    ~15, ->6
   12    21    > > GENERATOR_RETURN                                         

End of function nums

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.44 ms | 1403 KiB | 16 Q