3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen() { for($i = 1; $i <=3; $i++) { $resp = (yield $i); echo '$resp: '; var_dump($resp); } } $gen = gen(); foreach($gen as $out) { echo '$out: '; var_dump($out); echo $gen->send('Hi ' . $out); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/ROddn
function name:  (null)
number of ops:  17
compiled vars:  !0 = $gen, !1 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'gen'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   14     3      > FE_RESET_R                                       $4      !0, ->15
          4    > > FE_FETCH_R                                               $4, !1, ->15
   16     5    >   ECHO                                                     '%24out%3A+'
   17     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   18     9        INIT_METHOD_CALL                                         !0, 'send'
         10        CONCAT                                           ~6      'Hi+', !1
         11        SEND_VAL_EX                                              ~6
         12        DO_FCALL                                      0  $7      
         13        ECHO                                                     $7
   14    14      > JMP                                                      ->4
         15    >   FE_FREE                                                  $4
   19    16      > RETURN                                                   1

Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
Branch analysis from position: 3
filename:       /in/ROddn
function name:  gen
number of ops:  13
compiled vars:  !0 = $i, !1 = $resp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    5     1        ASSIGN                                                   !0, 1
          2      > JMP                                                      ->10
    7     3    >   YIELD                                            $3      !0
          4        ASSIGN                                                   !1, $3
    8     5        ECHO                                                     '%24resp%3A+'
    9     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
    5     9        PRE_INC                                                  !0
         10    >   IS_SMALLER_OR_EQUAL                                      !0, 3
         11      > JMPNZ                                                    ~7, ->3
   11    12    > > GENERATOR_RETURN                                         

End of function gen

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.06 ms | 1399 KiB | 16 Q