3v4l.org

run code in 300+ PHP versions simultaneously
<?php $g = function () { $r = yield "get me a number"; echo "Hey it's g, I've got a {$r}\n"; }; $gen = $g(); foreach ($gen as $generated) { echo "g asked to: {$generated}\n"; $gen->send(12); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/SAA9M
function name:  (null)
number of ops:  17
compiled vars:  !0 = $g, !1 = $gen, !2 = $generated
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          1        ASSIGN                                                   !0, ~3
    9     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0  $5      
          4        ASSIGN                                                   !1, $5
   11     5      > FE_RESET_R                                       $7      !1, ->15
          6    > > FE_FETCH_R                                               $7, !2, ->15
   12     7    >   ROPE_INIT                                     3  ~9      'g+asked+to%3A+'
          8        ROPE_ADD                                      1  ~9      ~9, !2
          9        ROPE_END                                      2  ~8      ~9, '%0A'
         10        ECHO                                                     ~8
   13    11        INIT_METHOD_CALL                                         !1, 'send'
         12        SEND_VAL_EX                                              12
         13        DO_FCALL                                      0          
   11    14      > JMP                                                      ->6
         15    >   FE_FREE                                                  $7
   14    16      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/SAA9M
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                            $1      'get+me+a+number'
          2        ASSIGN                                                   !0, $1
    6     3        ROPE_INIT                                     3  ~4      'Hey+it%27s+g%2C+I%27ve+got+a+'
          4        ROPE_ADD                                      1  ~4      ~4, !0
          5        ROPE_END                                      2  ~3      ~4, '%0A'
          6        ECHO                                                     ~3
    7     7      > GENERATOR_RETURN                                         

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
263.77 ms | 1000 KiB | 13 Q