3v4l.org

run code in 500+ PHP versions simultaneously
<?php function foo() { while (true) { yield mt_rand(1, 2) => 'foo'; } } $foo = foo(); $foo->next(); echo $foo->key(), ' => ', $foo->current(), PHP_EOL; $foo->next(); echo $foo->key(), ' => ', $foo->current(), PHP_EOL; $foo->next(); echo $foo->key(), ' => ', $foo->current(), PHP_EOL; $foo->next(); echo $foo->key(), ' => ', $foo->current(), PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/275iF
function name:  (null)
number of ops:  44
compiled vars:  !0 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                                   'foo'
          1        DO_FCALL                                          0  $1      
          2        ASSIGN                                                       !0, $1
   10     3        INIT_METHOD_CALL                                             !0, 'next'
          4        DO_FCALL                                          0          
   11     5        INIT_METHOD_CALL                                             !0, 'key'
          6        DO_FCALL                                          0  $4      
          7        ECHO                                                         $4
          8        ECHO                                                         '+%3D%3E+'
          9        INIT_METHOD_CALL                                             !0, 'current'
         10        DO_FCALL                                          0  $5      
         11        ECHO                                                         $5
         12        ECHO                                                         '%0A'
   12    13        INIT_METHOD_CALL                                             !0, 'next'
         14        DO_FCALL                                          0          
   13    15        INIT_METHOD_CALL                                             !0, 'key'
         16        DO_FCALL                                          0  $7      
         17        ECHO                                                         $7
         18        ECHO                                                         '+%3D%3E+'
         19        INIT_METHOD_CALL                                             !0, 'current'
         20        DO_FCALL                                          0  $8      
         21        ECHO                                                         $8
         22        ECHO                                                         '%0A'
   14    23        INIT_METHOD_CALL                                             !0, 'next'
         24        DO_FCALL                                          0          
   15    25        INIT_METHOD_CALL                                             !0, 'key'
         26        DO_FCALL                                          0  $10     
         27        ECHO                                                         $10
         28        ECHO                                                         '+%3D%3E+'
         29        INIT_METHOD_CALL                                             !0, 'current'
         30        DO_FCALL                                          0  $11     
         31        ECHO                                                         $11
         32        ECHO                                                         '%0A'
   16    33        INIT_METHOD_CALL                                             !0, 'next'
         34        DO_FCALL                                          0          
   17    35        INIT_METHOD_CALL                                             !0, 'key'
         36        DO_FCALL                                          0  $13     
         37        ECHO                                                         $13
         38        ECHO                                                         '+%3D%3E+'
         39        INIT_METHOD_CALL                                             !0, 'current'
         40        DO_FCALL                                          0  $14     
         41        ECHO                                                         $14
         42        ECHO                                                         '%0A'
         43      > RETURN                                                       1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
Branch analysis from position: 2
filename:       /in/275iF
function name:  foo
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                             
    4     1      > JMP                                                          ->7
    5     2    >   INIT_FCALL                                                   'mt_rand'
          3        SEND_VAL                                                     1
          4        SEND_VAL                                                     2
          5        DO_ICALL                                             $0      
          6        YIELD                                                        'foo', $0
    4     7    > > JMPNZ                                                        <true>, ->2
    7     8    > > GENERATOR_RETURN                                             

End of function foo

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.02 ms | 1452 KiB | 15 Q