3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); function generate_ints($n){ foreach ( range(0,$n-1) as $number) { yield $number; } } $gen = generate_ints(10); // iterable object can be used in foreach foreach ($gen as $g) { echo $gen->current(); $gen->next(); // echo $gen->next() meaningless b/c PHP generator::next() returns nothing! vs next($arr) next value. seehttp://php.net/manual/en/generator.next.php and http://us2.php.net/manual/en/iterator.next.php }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/cq4ZO
function name:  (null)
number of ops:  17
compiled vars:  !0 = $gen, !1 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
    9     3        INIT_FCALL                                               'generate_ints'
          4        SEND_VAL                                                 10
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !0, $3
   12     7      > FE_RESET_R                                       $5      !0, ->15
          8    > > FE_FETCH_R                                               $5, !1, ->15
   13     9    >   INIT_METHOD_CALL                                         !0, 'current'
         10        DO_FCALL                                      0  $6      
         11        ECHO                                                     $6
   14    12        INIT_METHOD_CALL                                         !0, 'next'
         13        DO_FCALL                                      0          
   12    14      > JMP                                                      ->8
         15    >   FE_FREE                                                  $5
   15    16      > RETURN                                                   1

Function generate_ints:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 11
filename:       /in/cq4ZO
function name:  generate_ints
number of ops:  13
compiled vars:  !0 = $n, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2        INIT_FCALL                                               'range'
          3        SEND_VAL                                                 0
          4        SUB                                              ~2      !0, 1
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7      > FE_RESET_R                                       $4      $3, ->11
          8    > > FE_FETCH_R                                               $4, !1, ->11
    5     9    >   YIELD                                                    !1
    4    10      > JMP                                                      ->8
         11    >   FE_FREE                                                  $4
    7    12      > GENERATOR_RETURN                                         

End of function generate_ints

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
232.54 ms | 1399 KiB | 18 Q