3v4l.org

run code in 300+ PHP versions simultaneously
<?php # Helper to simulate the while $posts = function() { static $posts = 20; $posts--; return $posts < 0 ?: $posts; }; $counter = 0; echo "Looping Posts".PHP_EOL; while( $posts() ) { $counter++; echo "Post: {$counter}".PHP_EOL; if( $counter % 4 == 1 ) { /* template A? */ echo ' (A)~~> Posts: 1, 5, 9, 13, 17, etc…'.PHP_EOL; } elseif( $counter % 4 == 2 ) { /* template B? */ echo ' (B)~~> Posts: 2, 6, 10, 14, 18, etc…'.PHP_EOL; } elseif( $counter % 4 == 3 ) { /* template C? */ echo ' (C)~~> Posts: 3, 7, 11, 15, 19, etc…'.PHP_EOL; } elseif( $counter % 4 == 0 ) { /* template D? */ echo ' (D)~~> Posts: 4, 8, 12, 16, 20, etc…'.PHP_EOL; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 5
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 5
Branch analysis from position: 32
Branch analysis from position: 5
Branch analysis from position: 29
filename:       /in/02bBO
function name:  (null)
number of ops:  33
compiled vars:  !0 = $posts, !1 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F02bBO%3A4%240'
          1        ASSIGN                                                   !0, ~2
   10     2        ASSIGN                                                   !1, 0
   11     3        ECHO                                                     'Looping+Posts%0A'
   12     4      > JMP                                                      ->29
   13     5    >   PRE_INC                                                  !1
   14     6        NOP                                                      
          7        FAST_CONCAT                                      ~6      'Post%3A+', !1
          8        CONCAT                                           ~7      ~6, '%0A'
          9        ECHO                                                     ~7
   15    10        MOD                                              ~8      !1, 4
         11        IS_EQUAL                                                 ~8, 1
         12      > JMPZ                                                     ~9, ->15
   17    13    >   ECHO                                                     '+%28A%29%7E%7E%3E+Posts%3A+1%2C+5%2C+9%2C+13%2C+17%2C+etc%E2%80%A6%0A'
         14      > JMP                                                      ->29
   19    15    >   MOD                                              ~10     !1, 4
         16        IS_EQUAL                                                 ~10, 2
         17      > JMPZ                                                     ~11, ->20
   21    18    >   ECHO                                                     '+%28B%29%7E%7E%3E+Posts%3A+2%2C+6%2C+10%2C+14%2C+18%2C+etc%E2%80%A6%0A'
         19      > JMP                                                      ->29
   23    20    >   MOD                                              ~12     !1, 4
         21        IS_EQUAL                                                 ~12, 3
         22      > JMPZ                                                     ~13, ->25
   25    23    >   ECHO                                                     '+%28C%29%7E%7E%3E+Posts%3A+3%2C+7%2C+11%2C+15%2C+19%2C+etc%E2%80%A6%0A'
         24      > JMP                                                      ->29
   27    25    >   MOD                                              ~14     !1, 4
         26        IS_EQUAL                                                 ~14, 0
         27      > JMPZ                                                     ~15, ->29
   29    28    >   ECHO                                                     '+%28D%29%7E%7E%3E+Posts%3A+4%2C+8%2C+12%2C+16%2C+20%2C+etc%E2%80%A6%0A'
   12    29    >   INIT_DYNAMIC_CALL                                        !0
         30        DO_FCALL                                      0  $16     
         31      > JMPNZ                                                    $16, ->5
   31    32    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F02bBO%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/02bBO
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $posts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                              !0
    6     1        PRE_DEC                                                  !0
    7     2        IS_SMALLER                                       ~2      !0, 0
          3        JMP_SET                                          ~3      ~2, ->5
          4        QM_ASSIGN                                        ~3      !0
          5      > RETURN                                                   ~3
    8     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F02bBO%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.25 ms | 1399 KiB | 13 Q