3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fiber = new Fiber(function() { $count = 3; echo "Start\n"; while(true) { Fiber::suspend(); // suspend the fiber echo "Are there results?\n"; $count--; if ($count === 0) { return; // We received the results, we stop } } }); $fiber->start(); // Initiates processing do { echo "Do something else\n"; $fiber->resume(); // Restart the fiber } while (!$fiber->isTerminated()); // The fiber has terminated echo "End\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 7
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/YrDZ0
function name:  (null)
number of ops:  16
compiled vars:  !0 = $fiber
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $1      'Fiber'
          1        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   13     2        SEND_VAL_EX                                              ~2
    2     3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   15     5        INIT_METHOD_CALL                                         !0, 'start'
          6        DO_FCALL                                      0          
   17     7    >   ECHO                                                     'Do+something+else%0A'
   18     8        INIT_METHOD_CALL                                         !0, 'resume'
          9        DO_FCALL                                      0          
   19    10        INIT_METHOD_CALL                                         !0, 'isTerminated'
         11        DO_FCALL                                      0  $7      
         12        BOOL_NOT                                         ~8      $7
         13      > JMPNZ                                                    ~8, ->7
   20    14    >   ECHO                                                     'End%0A'
         15      > 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 = 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/YrDZ0
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 3
    4     1        ECHO                                                     'Start%0A'
    5     2      > JMP                                                      ->10
    6     3    >   INIT_STATIC_METHOD_CALL                                  'Fiber', 'suspend'
          4        DO_FCALL                                      0          
    7     5        ECHO                                                     'Are+there+results%3F%0A'
    8     6        PRE_DEC                                                  !0
    9     7        IS_IDENTICAL                                             !0, 0
          8      > JMPZ                                                     ~4, ->10
   10     9    > > RETURN                                                   null
    5    10    > > JMPNZ                                                    <true>, ->3
   13    11    > > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.87 ms | 999 KiB | 14 Q