3v4l.org

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

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

End of function gen

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.42 ms | 1399 KiB | 16 Q