3v4l.org

run code in 300+ PHP versions simultaneously
<?php function count_to_ten() { $t = (yield from seven_eight()); echo '$'.var_dump($t); return 'ok'; } function seven_eight() { $k = yield;echo '#'; var_dump($k); foreach ([1, 2, 3] as $k => $v) { yield $v; } } $gen = count_to_ten(); foreach ($gen as $k => $num) { echo $gen->send('t'); echo "\n-$k -> $num \n"; } 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/PtmAD
function name:  (null)
number of ops:  24
compiled vars:  !0 = $gen, !1 = $num, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'count_to_ten'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   20     3      > FE_RESET_R                                       $5      !0, ->17
          4    > > FE_FETCH_R                                       ~6      $5, !1, ->17
          5    >   ASSIGN                                                   !2, ~6
          6        INIT_METHOD_CALL                                         !0, 'send'
          7        SEND_VAL_EX                                              't'
          8        DO_FCALL                                      0  $8      
          9        ECHO                                                     $8
   21    10        ROPE_INIT                                     5  ~10     '%0A-'
         11        ROPE_ADD                                      1  ~10     ~10, !2
         12        ROPE_ADD                                      2  ~10     ~10, '+-%3E+'
         13        ROPE_ADD                                      3  ~10     ~10, !1
         14        ROPE_END                                      4  ~9      ~10, '+%0A'
         15        ECHO                                                     ~9
   20    16      > JMP                                                      ->4
         17    >   FE_FREE                                                  $5
   24    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
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/PtmAD
function name:  count_to_ten
number of ops:  12
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    5     1        INIT_FCALL_BY_NAME                                       'seven_eight'
          2        DO_FCALL                                      0  $1      
          3        YIELD_FROM                                       ~2      $1
          4        ASSIGN                                                   !0, ~2
    6     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $4      
          8        CONCAT                                           ~5      '%24', $4
          9        ECHO                                                     ~5
    7    10      > GENERATOR_RETURN                                         
    8    11*     > 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 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 12
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 12
filename:       /in/PtmAD
function name:  seven_eight
number of ops:  14
compiled vars:  !0 = $k, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GENERATOR_CREATE                                         
   11     1        YIELD                                            $2      
          2        ASSIGN                                                   !0, $2
          3        ECHO                                                     '%23'
   12     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   13     7      > FE_RESET_R                                       $5      <array>, ->12
          8    > > FE_FETCH_R                                       ~6      $5, !1, ->12
          9    >   ASSIGN                                                   !0, ~6
   15    10        YIELD                                                    !1
   13    11      > JMP                                                      ->8
         12    >   FE_FREE                                                  $5
   17    13      > GENERATOR_RETURN                                         

End of function seven_eight

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.25 ms | 1403 KiB | 16 Q