3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen() { echo "yielding\n"; yield 24; echo "yielding again\n"; yield 33; echo "returning\n"; return 42; } $g = gen(); $g->next(); var_dump($g->valid()); var_dump($g->key()); var_dump($g->current()); $g->next(); var_dump($g->valid()); var_dump($g->key()); var_dump($g->current()); $g->next(); var_dump($g->valid()); var_dump($g->key()); var_dump($g->current());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/98g1n
function name:  (null)
number of ops:  55
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'gen'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   13     3        INIT_METHOD_CALL                                         !0, 'next'
          4        DO_FCALL                                      0          
   14     5        INIT_FCALL                                               'var_dump'
          6        INIT_METHOD_CALL                                         !0, 'valid'
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   15    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !0, 'key'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                                 
   16    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !0, 'current'
         17        DO_FCALL                                      0  $8      
         18        SEND_VAR                                                 $8
         19        DO_ICALL                                                 
   17    20        INIT_METHOD_CALL                                         !0, 'next'
         21        DO_FCALL                                      0          
   18    22        INIT_FCALL                                               'var_dump'
         23        INIT_METHOD_CALL                                         !0, 'valid'
         24        DO_FCALL                                      0  $11     
         25        SEND_VAR                                                 $11
         26        DO_ICALL                                                 
   19    27        INIT_FCALL                                               'var_dump'
         28        INIT_METHOD_CALL                                         !0, 'key'
         29        DO_FCALL                                      0  $13     
         30        SEND_VAR                                                 $13
         31        DO_ICALL                                                 
   20    32        INIT_FCALL                                               'var_dump'
         33        INIT_METHOD_CALL                                         !0, 'current'
         34        DO_FCALL                                      0  $15     
         35        SEND_VAR                                                 $15
         36        DO_ICALL                                                 
   21    37        INIT_METHOD_CALL                                         !0, 'next'
         38        DO_FCALL                                      0          
   22    39        INIT_FCALL                                               'var_dump'
         40        INIT_METHOD_CALL                                         !0, 'valid'
         41        DO_FCALL                                      0  $18     
         42        SEND_VAR                                                 $18
         43        DO_ICALL                                                 
   23    44        INIT_FCALL                                               'var_dump'
         45        INIT_METHOD_CALL                                         !0, 'key'
         46        DO_FCALL                                      0  $20     
         47        SEND_VAR                                                 $20
         48        DO_ICALL                                                 
   24    49        INIT_FCALL                                               'var_dump'
         50        INIT_METHOD_CALL                                         !0, 'current'
         51        DO_FCALL                                      0  $22     
         52        SEND_VAR                                                 $22
         53        DO_ICALL                                                 
         54      > RETURN                                                   1

Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/98g1n
function name:  gen
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        ECHO                                                     'yielding%0A'
    5     2        YIELD                                                    24
    6     3        ECHO                                                     'yielding+again%0A'
    7     4        YIELD                                                    33
    8     5        ECHO                                                     'returning%0A'
    9     6      > GENERATOR_RETURN                                         
   10     7*     > GENERATOR_RETURN                                         

End of function gen

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.81 ms | 1403 KiB | 16 Q