3v4l.org

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

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

End of function gen

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.79 ms | 1403 KiB | 14 Q