3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test() { if (1 < 0) { yield 'a'; } } function test2() { yield 'a'; yield 'b'; } $test = test(); $test2 = test2(); var_dump($test->valid(), $test2->valid()); echo 'Iterate test', PHP_EOL; foreach ($test as $a) { echo $a, PHP_EOL; } echo 'Iterate test2', PHP_EOL; foreach ($test2 as $a) { echo $a, PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 21
filename:       /in/eLA6p
function name:  (null)
number of ops:  31
compiled vars:  !0 = $test, !1 = $test2, !2 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'test'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   17     3        INIT_FCALL                                               'test2'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   19     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'valid'
          8        DO_FCALL                                      0  $7      
          9        SEND_VAR                                                 $7
         10        INIT_METHOD_CALL                                         !1, 'valid'
         11        DO_FCALL                                      0  $8      
         12        SEND_VAR                                                 $8
         13        DO_ICALL                                                 
   21    14        ECHO                                                     'Iterate+test'
         15        ECHO                                                     '%0A'
   23    16      > FE_RESET_R                                       $10     !0, ->21
         17    > > FE_FETCH_R                                               $10, !2, ->21
   24    18    >   ECHO                                                     !2
         19        ECHO                                                     '%0A'
   23    20      > JMP                                                      ->17
         21    >   FE_FREE                                                  $10
   27    22        ECHO                                                     'Iterate+test2'
         23        ECHO                                                     '%0A'
   29    24      > FE_RESET_R                                       $11     !1, ->29
         25    > > FE_FETCH_R                                               $11, !2, ->29
   30    26    >   ECHO                                                     !2
         27        ECHO                                                     '%0A'
   29    28      > JMP                                                      ->25
         29    >   FE_FREE                                                  $11
   31    30      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 3
Branch analysis from position: 2
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
filename:       /in/eLA6p
function name:  test
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    5     1      > JMPZ                                                     <false>, ->3
    6     2    >   YIELD                                                    'a'
    8     3    > > GENERATOR_RETURN                                         

End of function test

Function test2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/eLA6p
function name:  test2
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GENERATOR_CREATE                                         
   12     1        YIELD                                                    'a'
   13     2        YIELD                                                    'b'
   14     3      > GENERATOR_RETURN                                         

End of function test2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.93 ms | 1403 KiB | 18 Q