3v4l.org

run code in 300+ PHP versions simultaneously
<?php function count_to_ten() { foreach (['f1', 'f2', 'f3'] as $file) { $t = yield; if ($t == 't') { } echo '$'.($t)."\n"; yield from seven_eight(); } return 'ok'; } function seven_eight() { foreach ([1, 2, 3] as $k => $v) { yield $v; } } $gen = count_to_ten(); foreach ($gen as $k => $num) { echo "\n-$k -> $num \n";echo $gen->send('t'); } var_dump( $gen->getReturn());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/Q81Te
function name:  (null)
number of ops:  24
compiled vars:  !0 = $gen, !1 = $num, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'count_to_ten'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   24     3      > FE_RESET_R                                       $5      !0, ->17
          4    > > FE_FETCH_R                                       ~6      $5, !1, ->17
          5    >   ASSIGN                                                   !2, ~6
   25     6        ROPE_INIT                                     5  ~9      '%0A-'
          7        ROPE_ADD                                      1  ~9      ~9, !2
          8        ROPE_ADD                                      2  ~9      ~9, '+-%3E+'
          9        ROPE_ADD                                      3  ~9      ~9, !1
         10        ROPE_END                                      4  ~8      ~9, '+%0A'
         11        ECHO                                                     ~8
         12        INIT_METHOD_CALL                                         !0, 'send'
         13        SEND_VAL_EX                                              't'
         14        DO_FCALL                                      0  $12     
         15        ECHO                                                     $12
   24    16      > JMP                                                      ->4
         17    >   FE_FREE                                                  $5
   28    18        INIT_FCALL                                               'var_dump'
         19        INIT_METHOD_CALL                                         !0, 'getReturn'
         20        DO_FCALL                                      0  $13     
         21        SEND_VAR                                                 $13
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Function count_to_ten:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 15
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 7
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 7
Branch analysis from position: 15
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 15
filename:       /in/Q81Te
function name:  count_to_ten
number of ops:  18
compiled vars:  !0 = $file, !1 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1      > FE_RESET_R                                       $2      <array>, ->15
          2    > > FE_FETCH_R                                               $2, !0, ->15
    5     3    >   YIELD                                            $3      
          4        ASSIGN                                                   !1, $3
    6     5        IS_EQUAL                                                 !1, 't'
          6      > JMPZ                                                     ~5, ->7
    9     7    >   CONCAT                                           ~6      '%24', !1
          8        CONCAT                                           ~7      ~6, '%0A'
          9        ECHO                                                     ~7
   10    10        INIT_FCALL_BY_NAME                                       'seven_eight'
         11        DO_FCALL                                      0  $8      
         12        YIELD_FROM                                       ~9      $8
         13        FREE                                                     ~9
    4    14      > JMP                                                      ->2
         15    >   FE_FREE                                                  $2
   13    16      > GENERATOR_RETURN                                         
   14    17*     > GENERATOR_RETURN                                         

End of function count_to_ten

Function seven_eight:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 6
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 6
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 6
filename:       /in/Q81Te
function name:  seven_eight
number of ops:  8
compiled vars:  !0 = $v, !1 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   GENERATOR_CREATE                                         
   17     1      > FE_RESET_R                                       $2      <array>, ->6
          2    > > FE_FETCH_R                                       ~3      $2, !0, ->6
          3    >   ASSIGN                                                   !1, ~3
   19     4        YIELD                                                    !0
   17     5      > JMP                                                      ->2
          6    >   FE_FREE                                                  $2
   21     7      > GENERATOR_RETURN                                         

End of function seven_eight

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.76 ms | 1407 KiB | 16 Q