3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { echo 'In generator func foo',"\n"; $string = (yield); echo $string; /*for ($i = 1; $i <= 3; $i++) { yield $i; }*/ } $generator = foo(); $generator->send('Hello world!'); //foreach ($generator as $value) echo "$value\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vjRTm
function name:  (null)
number of ops:  7
compiled vars:  !0 = $generator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'foo'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   11     3        INIT_METHOD_CALL                                         !0, 'send'
          4        SEND_VAL_EX                                              'Hello+world%21'
          5        DO_FCALL                                      0          
   12     6      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/vjRTm
function name:  foo
number of ops:  7
compiled vars:  !0 = $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'
    4     3        YIELD                                            $1      
          4        ASSIGN                                                   !0, $1
    5     5        ECHO                                                     !0
    9     6      > GENERATOR_RETURN                                         

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.17 ms | 1397 KiB | 14 Q