3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { echo "Gen1\n"; $a = yield 1; echo "Resumed. a is $a\n"; } function gen2() { echo "Gen2\n"; $b = yield 2; echo "Resumed. b is $b\n"; } function yf() { yield from gen1(); echo "Between\n"; yield from gen2(); } $g = yf(); echo "Autoprime"; var_dump($g->current()); echo "Sending\n"; var_dump($g->send(42)); echo "Done\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i7Sbi
function name:  (null)
number of ops:  18
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'yf'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   22     3        ECHO                                                     'Autoprime'
   23     4        INIT_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'current'
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
   24     9        ECHO                                                     'Sending%0A'
   25    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !0, 'send'
         12        SEND_VAL_EX                                              42
         13        DO_FCALL                                      0  $5      
         14        SEND_VAR                                                 $5
         15        DO_ICALL                                                 
   26    16        ECHO                                                     'Done%0A'
         17      > RETURN                                                   1

Function gen1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/i7Sbi
function name:  gen1
number of ops:  9
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        ECHO                                                     'Gen1%0A'
    5     2        YIELD                                            $1      1
          3        ASSIGN                                                   !0, $1
    6     4        ROPE_INIT                                     3  ~4      'Resumed.+a+is+'
          5        ROPE_ADD                                      1  ~4      ~4, !0
          6        ROPE_END                                      2  ~3      ~4, '%0A'
          7        ECHO                                                     ~3
    7     8      > GENERATOR_RETURN                                         

End of function gen1

Function gen2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/i7Sbi
function name:  gen2
number of ops:  9
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   GENERATOR_CREATE                                         
   10     1        ECHO                                                     'Gen2%0A'
   11     2        YIELD                                            $1      2
          3        ASSIGN                                                   !0, $1
   12     4        ROPE_INIT                                     3  ~4      'Resumed.+b+is+'
          5        ROPE_ADD                                      1  ~4      ~4, !0
          6        ROPE_END                                      2  ~3      ~4, '%0A'
          7        ECHO                                                     ~3
   13     8      > GENERATOR_RETURN                                         

End of function gen2

Function yf:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/i7Sbi
function name:  yf
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   GENERATOR_CREATE                                         
   16     1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $0      
          3        YIELD_FROM                                       ~1      $0
          4        FREE                                                     ~1
   17     5        ECHO                                                     'Between%0A'
   18     6        INIT_FCALL                                               'gen2'
          7        DO_FCALL                                      0  $2      
          8        YIELD_FROM                                       ~3      $2
          9        FREE                                                     ~3
   19    10      > GENERATOR_RETURN                                         

End of function yf

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.4 ms | 1403 KiB | 18 Q