3v4l.org

run code in 300+ PHP versions simultaneously
<?php function printer() { for ($i = 0; $i < 10; $i++) { $string = (yield $i); var_dump($string); } } $printer = printer(); echo 'current: '; var_dump($printer->current()); $printer->send('Hello world!'); echo 'current: '; var_dump($printer->current()); $printer->next(); echo 'current: '; var_dump($printer->current()); $printer->send('Bye world!'); echo 'current: '; var_dump($printer->current());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vbbZM
function name:  (null)
number of ops:  36
compiled vars:  !0 = $printer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'printer'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   10     3        ECHO                                                     'current%3A+'
          4        INIT_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'current'
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
   11     9        INIT_METHOD_CALL                                         !0, 'send'
         10        SEND_VAL_EX                                              'Hello+world%21'
         11        DO_FCALL                                      0          
   12    12        ECHO                                                     'current%3A+'
         13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !0, 'current'
         15        DO_FCALL                                      0  $6      
         16        SEND_VAR                                                 $6
         17        DO_ICALL                                                 
   13    18        INIT_METHOD_CALL                                         !0, 'next'
         19        DO_FCALL                                      0          
   14    20        ECHO                                                     'current%3A+'
         21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !0, 'current'
         23        DO_FCALL                                      0  $9      
         24        SEND_VAR                                                 $9
         25        DO_ICALL                                                 
   15    26        INIT_METHOD_CALL                                         !0, 'send'
         27        SEND_VAL_EX                                              'Bye+world%21'
         28        DO_FCALL                                      0          
   16    29        ECHO                                                     'current%3A+'
         30        INIT_FCALL                                               'var_dump'
         31        INIT_METHOD_CALL                                         !0, 'current'
         32        DO_FCALL                                      0  $12     
         33        SEND_VAR                                                 $12
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Function printer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/vbbZM
function name:  printer
number of ops:  12
compiled vars:  !0 = $i, !1 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   GENERATOR_CREATE                                         
    3     1        ASSIGN                                                   !0, 0
          2      > JMP                                                      ->9
    4     3    >   YIELD                                            $3      !0
          4        ASSIGN                                                   !1, $3
    5     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
    3     8        PRE_INC                                                  !0
          9    >   IS_SMALLER                                               !0, 10
         10      > JMPNZ                                                    ~7, ->3
    7    11    > > GENERATOR_RETURN                                         

End of function printer

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.72 ms | 1452 KiB | 15 Q