3v4l.org

run code in 300+ PHP versions simultaneously
<?php $generator = (function() { $count = 3; echo "Début\n"; while(true) { yield; // on suspend la fonction (le générateur) echo "Il y a des résultats ?\n"; $count--; if ($count === 0) { return; // On a reçu les résultats, on s'arrête } } })(); $generator->current(); // Initie le traitement do { echo "Faire autre chose\n"; $generator->next(); // On relance la fonction (on reprend au "yield") } while ($generator->valid()); // La fonction s'est terminée ? echo "Fin\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 6
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/Ogjug
function name:  (null)
number of ops:  14
compiled vars:  !0 = $generator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
   13     1        INIT_DYNAMIC_CALL                                        ~1
          2        DO_FCALL                                      0  $2      
    2     3        ASSIGN                                                   !0, $2
   15     4        INIT_METHOD_CALL                                         !0, 'current'
          5        DO_FCALL                                      0          
   17     6    >   ECHO                                                     'Faire+autre+chose%0A'
   18     7        INIT_METHOD_CALL                                         !0, 'next'
          8        DO_FCALL                                      0          
   19     9        INIT_METHOD_CALL                                         !0, 'valid'
         10        DO_FCALL                                      0  $6      
         11      > JMPNZ                                                    $6, ->6
   20    12    >   ECHO                                                     'Fin%0A'
         13      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 4
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 10
filename:       /in/Ogjug
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   GENERATOR_CREATE                                         
    3     1        ASSIGN                                                   !0, 3
    4     2        ECHO                                                     'D%C3%A9but%0A'
    5     3      > JMP                                                      ->10
    6     4    >   YIELD                                                    
    7     5        ECHO                                                     'Il+y+a+des+r%C3%A9sultats+%3F%0A'
    8     6        PRE_DEC                                                  !0
    9     7        IS_IDENTICAL                                             !0, 0
          8      > JMPZ                                                     ~4, ->10
   10     9    > > GENERATOR_RETURN                                         
    5    10    > > JMPNZ                                                    <true>, ->4
   13    11    > > GENERATOR_RETURN                                         

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.34 ms | 996 KiB | 13 Q