3v4l.org

run code in 300+ PHP versions simultaneously
<?php function count_to_ten() { $i = 1; $cmd = yield $i; if ($cmd == 't') { echo "close"; return false; } yield 3 => 2; yield from [3, 4]; yield from new ArrayIterator([5, 6]); yield from seven_eight(); return yield from nine_ten(); } function seven_eight() { yield 7; yield from eight(); } function eight() { yield 8; } function nine_ten() { yield 9; return 10; } $gen = count_to_ten(); foreach ($gen as $k => $num) { echo "$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 = 16
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/9A5UX
function name:  (null)
number of ops:  23
compiled vars:  !0 = $gen, !1 = $num, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'count_to_ten'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   32     3      > FE_RESET_R                                       $5      !0, ->16
          4    > > FE_FETCH_R                                       ~6      $5, !1, ->16
          5    >   ASSIGN                                                   !2, ~6
   33     6        ROPE_INIT                                     4  ~9      !2
          7        ROPE_ADD                                      1  ~9      ~9, '+-%3E+'
          8        ROPE_ADD                                      2  ~9      ~9, !1
          9        ROPE_END                                      3  ~8      ~9, '+%0A'
         10        ECHO                                                     ~8
   34    11        INIT_METHOD_CALL                                         !0, 'send'
         12        SEND_VAL_EX                                              't'
         13        DO_FCALL                                      0  $11     
         14        ECHO                                                     $11
   32    15      > JMP                                                      ->4
         16    >   FE_FREE                                                  $5
   36    17        INIT_FCALL                                               'var_dump'
         18        INIT_METHOD_CALL                                         !0, 'getReturn'
         19        DO_FCALL                                      0  $12     
         20        SEND_VAR                                                 $12
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function count_to_ten:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/9A5UX
function name:  count_to_ten
number of ops:  25
compiled vars:  !0 = $i, !1 = $cmd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        ASSIGN                                                   !0, 1
    5     2        YIELD                                            $3      !0
          3        ASSIGN                                                   !1, $3
    6     4        IS_EQUAL                                                 !1, 't'
          5      > JMPZ                                                     ~5, ->8
    7     6    >   ECHO                                                     'close'
    8     7      > GENERATOR_RETURN                                         
   10     8    >   YIELD                                                    2, 3
   11     9        YIELD_FROM                                       ~7      <array>
         10        FREE                                                     ~7
   12    11        NEW                                              $8      'ArrayIterator'
         12        SEND_VAL_EX                                              <array>
         13        DO_FCALL                                      0          
         14        YIELD_FROM                                       ~10     $8
         15        FREE                                                     ~10
   13    16        INIT_FCALL_BY_NAME                                       'seven_eight'
         17        DO_FCALL                                      0  $11     
         18        YIELD_FROM                                       ~12     $11
         19        FREE                                                     ~12
   14    20        INIT_FCALL_BY_NAME                                       'nine_ten'
         21        DO_FCALL                                      0  $13     
         22        YIELD_FROM                                       ~14     $13
         23      > GENERATOR_RETURN                                         
   15    24*     > GENERATOR_RETURN                                         

End of function count_to_ten

Function seven_eight:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/9A5UX
function name:  seven_eight
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   GENERATOR_CREATE                                         
   18     1        YIELD                                                    7
   19     2        INIT_FCALL_BY_NAME                                       'eight'
          3        DO_FCALL                                      0  $1      
          4        YIELD_FROM                                       ~2      $1
          5        FREE                                                     ~2
   20     6      > GENERATOR_RETURN                                         

End of function seven_eight

Function eight:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/9A5UX
function name:  eight
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   GENERATOR_CREATE                                         
   23     1        YIELD                                                    8
   24     2      > GENERATOR_RETURN                                         

End of function eight

Function nine_ten:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/9A5UX
function name:  nine_ten
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   GENERATOR_CREATE                                         
   27     1        YIELD                                                    9
   28     2      > GENERATOR_RETURN                                         
   29     3*     > GENERATOR_RETURN                                         

End of function nine_ten

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.16 ms | 1403 KiB | 16 Q