3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen() { var_dump(yield 'foo'); var_dump(yield 'bar'); } $gen = gen(); var_dump("OUT".$gen->current()); var_dump("OUT".$gen->current()); var_dump("OUT".$gen->send('something'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sPSIA
function name:  (null)
number of ops:  23
compiled vars:  !0 = $gen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'gen'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
    9     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'current'
          5        DO_FCALL                                      0  $3      
          6        CONCAT                                           ~4      'OUT', $3
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                                 
   10     9        INIT_FCALL                                               'var_dump'
         10        INIT_METHOD_CALL                                         !0, 'current'
         11        DO_FCALL                                      0  $6      
         12        CONCAT                                           ~7      'OUT', $6
         13        SEND_VAL                                                 ~7
         14        DO_ICALL                                                 
   11    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !0, 'send'
         17        SEND_VAL_EX                                              'something'
         18        DO_FCALL                                      0  $9      
         19        CONCAT                                           ~10     'OUT', $9
         20        SEND_VAL                                                 ~10
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/sPSIA
function name:  gen
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        INIT_FCALL                                               'var_dump'
          2        YIELD                                            $0      'foo'
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
    5     5        INIT_FCALL                                               'var_dump'
          6        YIELD                                            $2      'bar'
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
    6     9      > GENERATOR_RETURN                                         

End of function gen

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.98 ms | 1390 KiB | 16 Q