3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('error_reporting', -1); ini_set('display_errors', 'on'); $a = []; function generator() { global $a; foreach($a as $i){ yield $i; } $a = []; } $generator = generator(); if ($generator->valid()) { foreach($generator as $i) { echo $i; } } else { echo 'Nothing'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m1MJd
function name:  (null)
number of ops:  23
compiled vars:  !0 = $a, !1 = $generator, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'error_reporting'
          2        SEND_VAL                                                 -1
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'ini_set'
          5        SEND_VAL                                                 'display_errors'
          6        SEND_VAL                                                 'on'
          7        DO_ICALL                                                 
    6     8        ASSIGN                                                   !0, <array>
   17     9        INIT_FCALL                                               'generator'
         10        DO_FCALL                                      0  $6      
         11        ASSIGN                                                   !1, $6
   18    12        INIT_METHOD_CALL                                         !1, 'valid'
         13        DO_FCALL                                      0  $8      
         14      > JMPZ                                                     $8, ->21
   19    15    > > FE_RESET_R                                       $9      !1, ->19
         16    > > FE_FETCH_R                                               $9, !2, ->19
   20    17    >   ECHO                                                     !2
   19    18      > JMP                                                      ->16
         19    >   FE_FREE                                                  $9
         20      > JMP                                                      ->22
   23    21    >   ECHO                                                     'Nothing'
   24    22    > > RETURN                                                   1

Function generator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 6
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 6
filename:       /in/m1MJd
function name:  generator
number of ops:  9
compiled vars:  !0 = $a, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   GENERATOR_CREATE                                         
   10     1        BIND_GLOBAL                                              !0, 'a'
   11     2      > FE_RESET_R                                       $2      !0, ->6
          3    > > FE_FETCH_R                                               $2, !1, ->6
   12     4    >   YIELD                                                    !1
   11     5      > JMP                                                      ->3
          6    >   FE_FREE                                                  $2
   14     7        ASSIGN                                                   !0, <array>
   15     8      > GENERATOR_RETURN                                         

End of function generator

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.78 ms | 1403 KiB | 16 Q