3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { echo 'In generator func foo',"\n"; for ($i = 11; $i < 14; $i++) { $string=(yield $i); if (isset($string)) { echo "Sent value is $string","\n"; } } echo 'generator done and closed.',"\n"; return; } $generator = foo(); foreach ($generator as $value) { echo "Fetched value is $value\n"; if ($value == 13) { $generator->send('Hello World'); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/lod2n
function name:  (null)
number of ops:  17
compiled vars:  !0 = $generator, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'foo'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   16     3      > FE_RESET_R                                       $4      !0, ->15
          4    > > FE_FETCH_R                                               $4, !1, ->15
   18     5    >   ROPE_INIT                                     3  ~6      'Fetched+value+is+'
          6        ROPE_ADD                                      1  ~6      ~6, !1
          7        ROPE_END                                      2  ~5      ~6, '%0A'
          8        ECHO                                                     ~5
   19     9        IS_EQUAL                                                 !1, 13
         10      > JMPZ                                                     ~8, ->14
   20    11    >   INIT_METHOD_CALL                                         !0, 'send'
         12        SEND_VAL_EX                                              'Hello+World'
         13        DO_FCALL                                      0          
   16    14    > > JMP                                                      ->4
         15    >   FE_FREE                                                  $4
   23    16      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 5
Branch analysis from position: 16
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 5
Branch analysis from position: 16
Branch analysis from position: 5
Branch analysis from position: 13
filename:       /in/lod2n
function name:  foo
number of ops:  20
compiled vars:  !0 = $i, !1 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   GENERATOR_CREATE                                         
    3     1        ECHO                                                     'In+generator+func+foo'
          2        ECHO                                                     '%0A'
    5     3        ASSIGN                                                   !0, 11
          4      > JMP                                                      ->14
    6     5    >   YIELD                                            $3      !0
          6        ASSIGN                                                   !1, $3
    7     7        ISSET_ISEMPTY_CV                                         !1
          8      > JMPZ                                                     ~5, ->13
    8     9    >   NOP                                                      
         10        FAST_CONCAT                                      ~6      'Sent+value+is+', !1
         11        ECHO                                                     ~6
         12        ECHO                                                     '%0A'
    5    13    >   PRE_INC                                                  !0
         14    >   IS_SMALLER                                               !0, 14
         15      > JMPNZ                                                    ~8, ->5
   12    16    >   ECHO                                                     'generator+done+and+closed.'
         17        ECHO                                                     '%0A'
   13    18      > GENERATOR_RETURN                                         
   14    19*     > GENERATOR_RETURN                                         

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.6 ms | 1402 KiB | 14 Q