3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { yield 1; yield 2; // return 42; } $bar = foo(); foreach ($bar as $val) { var_dump($val); } var_dump($bar->getReturn()); var_dump($bar->current()); $bar->send(21); var_dump($bar->current()); var_dump($bar->getReturn());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/9haTo
function name:  (null)
number of ops:  34
compiled vars:  !0 = $bar, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'foo'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   10     3      > FE_RESET_R                                       $4      !0, ->9
          4    > > FE_FETCH_R                                               $4, !1, ->9
          5    >   INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > JMP                                                      ->4
          9    >   FE_FREE                                                  $4
   12    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !0, 'getReturn'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                                 
   14    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !0, 'current'
         17        DO_FCALL                                      0  $8      
         18        SEND_VAR                                                 $8
         19        DO_ICALL                                                 
   15    20        INIT_METHOD_CALL                                         !0, 'send'
         21        SEND_VAL_EX                                              21
         22        DO_FCALL                                      0          
   16    23        INIT_FCALL                                               'var_dump'
         24        INIT_METHOD_CALL                                         !0, 'current'
         25        DO_FCALL                                      0  $11     
         26        SEND_VAR                                                 $11
         27        DO_ICALL                                                 
   18    28        INIT_FCALL                                               'var_dump'
         29        INIT_METHOD_CALL                                         !0, 'getReturn'
         30        DO_FCALL                                      0  $13     
         31        SEND_VAR                                                 $13
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

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

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.77 ms | 1403 KiB | 16 Q