3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { echo 'In generator func foo',"\n"; for ($i = 1; $i < 4; $i++) { $string=(yield $i); if (isset($string)) { echo $string,"\n"; } } echo 'generator done and closed.',"\n"; return; } $generator = foo(); foreach ($generator as $value) { if ($value == 3) { $generator->send('Hello World'); } echo "$value\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/nFb2I
function name:  (null)
number of ops:  16
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, ->14
          4    > > FE_FETCH_R                                               $4, !1, ->14
   17     5    >   IS_EQUAL                                                 !1, 3
          6      > JMPZ                                                     ~5, ->10
   18     7    >   INIT_METHOD_CALL                                         !0, 'send'
          8        SEND_VAL_EX                                              'Hello+World'
          9        DO_FCALL                                      0          
   20    10    >   NOP                                                      
         11        FAST_CONCAT                                      ~7      !1, '%0A'
         12        ECHO                                                     ~7
   16    13      > JMP                                                      ->4
         14    >   FE_FREE                                                  $4
   21    15      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
Branch analysis from position: 5
Branch analysis from position: 11
filename:       /in/nFb2I
function name:  foo
number of ops:  18
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, 1
          4      > JMP                                                      ->12
    6     5    >   YIELD                                            $3      !0
          6        ASSIGN                                                   !1, $3
    7     7        ISSET_ISEMPTY_CV                                         !1
          8      > JMPZ                                                     ~5, ->11
    8     9    >   ECHO                                                     !1
         10        ECHO                                                     '%0A'
    5    11    >   PRE_INC                                                  !0
         12    >   IS_SMALLER                                               !0, 4
         13      > JMPNZ                                                    ~7, ->5
   12    14    >   ECHO                                                     'generator+done+and+closed.'
         15        ECHO                                                     '%0A'
   13    16      > GENERATOR_RETURN                                         
   14    17*     > GENERATOR_RETURN                                         

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.56 ms | 1402 KiB | 14 Q