3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE html> <html> <head> <title>A loop of your own</title> <link type='text/css' rel='stylesheet' href='style.css'/> </head> <body> <?php //Add while loop below echo "<p>We will flip until we have heads.</p>"; $flipCount = 1; $headCount = 0; $tailCount = 0; while($headCount or $tailCount < 3) { $num = rand(0,1); if($num > 0.5) { echo "Heads. "; $headCount ++; $tailCount = 0; } else { echo "Tails. "; $headCount = 0; $tailCount ++; } if($headCount == 3) { echo "Congratulations! You got 3 heads in a row! It took you $flipCount tries."; } elseif($tailCount == 3) { echo "Congratulations! You got 3 tails in a row! It took you $flipCount tries."; } else { echo "No luck yet. You haven't gotten it after $flipCount tries.<br />"; } $flipCount ++; } ?> </body> </html>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 47) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 6
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 47) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
Branch analysis from position: 42
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 34
2 jumps found. (Code = 47) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
Branch analysis from position: 42
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
Branch analysis from position: 27
Branch analysis from position: 42
filename:       /in/89X4n
function name:  (null)
number of ops:  45
compiled vars:  !0 = $flipCount, !1 = $headCount, !2 = $tailCount, !3 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3C%21DOCTYPE+html%3E%0A%3Chtml%3E%0A++++%3Chead%3E%0A%09%09%3Ctitle%3EA+loop+of+your+own%3C%2Ftitle%3E%0A++++++++%3Clink+type%3D%27text%2Fcss%27+rel%3D%27stylesheet%27+href%3D%27style.css%27%2F%3E%0A%09%3C%2Fhead%3E%0A%09%3Cbody%3E%0A++++'
   10     1        ECHO                                                     '%3Cp%3EWe+will+flip+until+we+have+heads.%3C%2Fp%3E'
   11     2        ASSIGN                                                   !0, 1
   12     3        ASSIGN                                                   !1, 0
   13     4        ASSIGN                                                   !2, 0
   14     5      > JMP                                                      ->39
   15     6    >   INIT_FCALL                                               'rand'
          7        SEND_VAL                                                 0
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !3, $7
   17    11        IS_SMALLER                                               0.5, !3
         12      > JMPZ                                                     ~9, ->17
   18    13    >   ECHO                                                     'Heads.+'
   19    14        PRE_INC                                                  !1
   20    15        ASSIGN                                                   !2, 0
         16      > JMP                                                      ->20
   23    17    >   ECHO                                                     'Tails.+'
   24    18        ASSIGN                                                   !1, 0
   25    19        PRE_INC                                                  !2
   28    20    >   IS_EQUAL                                                 !1, 3
         21      > JMPZ                                                     ~14, ->27
   29    22    >   ROPE_INIT                                     3  ~16     'Congratulations%21+You+got+3+heads+in+a+row%21+It+took+you+'
         23        ROPE_ADD                                      1  ~16     ~16, !0
         24        ROPE_END                                      2  ~15     ~16, '+tries.'
         25        ECHO                                                     ~15
         26      > JMP                                                      ->38
   31    27    >   IS_EQUAL                                                 !2, 3
         28      > JMPZ                                                     ~18, ->34
   32    29    >   ROPE_INIT                                     3  ~20     'Congratulations%21+You+got+3+tails+in+a+row%21+It+took+you+'
         30        ROPE_ADD                                      1  ~20     ~20, !0
         31        ROPE_END                                      2  ~19     ~20, '+tries.'
         32        ECHO                                                     ~19
         33      > JMP                                                      ->38
   35    34    >   ROPE_INIT                                     3  ~23     'No+luck+yet.+You+haven%27t+gotten+it+after+'
         35        ROPE_ADD                                      1  ~23     ~23, !0
         36        ROPE_END                                      2  ~22     ~23, '+tries.%3Cbr+%2F%3E'
         37        ECHO                                                     ~22
   37    38    >   PRE_INC                                                  !0
   14    39    > > JMPNZ_EX                                         ~26     !1, ->42
         40    >   IS_SMALLER                                       ~27     !2, 3
         41        BOOL                                             ~26     ~27
         42    > > JMPNZ                                                    ~26, ->6
   40    43    >   ECHO                                                     '++++%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   41    44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.2 ms | 1392 KiB | 15 Q