3v4l.org

run code in 300+ PHP versions simultaneously
<?php $gen = (function() { yield 1; yield 2; return 3; })(); echo $gen->getReturn(), PHP_EOL; foreach ($gen as $val) { echo $val, PHP_EOL; } echo $gen->getReturn(), PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/WcXb5
function name:  (null)
number of ops:  19
compiled vars:  !0 = $gen, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FWcXb5%3A3%240'
    8     1        INIT_DYNAMIC_CALL                                        ~2
          2        DO_FCALL                                      0  $3      
    3     3        ASSIGN                                                   !0, $3
   10     4        INIT_METHOD_CALL                                         !0, 'getReturn'
          5        DO_FCALL                                      0  $5      
          6        ECHO                                                     $5
          7        ECHO                                                     '%0A'
   12     8      > FE_RESET_R                                       $6      !0, ->13
          9    > > FE_FETCH_R                                               $6, !1, ->13
   13    10    >   ECHO                                                     !1
         11        ECHO                                                     '%0A'
   12    12      > JMP                                                      ->9
         13    >   FE_FREE                                                  $6
   16    14        INIT_METHOD_CALL                                         !0, 'getReturn'
         15        DO_FCALL                                      0  $7      
         16        ECHO                                                     $7
         17        ECHO                                                     '%0A'
         18      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FWcXb5%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/WcXb5
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                                    1
    5     2        YIELD                                                    2
    7     3      > GENERATOR_RETURN                                         
    8     4*     > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FWcXb5%3A3%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.27 ms | 1395 KiB | 13 Q