3v4l.org

run code in 300+ PHP versions simultaneously
Der Befehl rand(1,6) liefert eine Zufallszahl zwischen 1 und 6. Mittels einer Schleife soll er sooft aufgerufen werden bis eine 6 "gewürfelt" wurde. Dann soll die Anzahl der Schleifendurchgänge ausgegeben werden. <br> <br> <br> <br> <?php $zaehler=1; $zufall1=rand(1,6); $zufall2=rand(1,6); while($zufall1!=6 || zufall2!=6) { echo($zufall); $zufall=rand(1,6); $zufall=rand(1,6); $zaehler++; } echo("<p>Anzahl der Würfe:".$zaehler); ?> Die Übung soll so ergänzt werden, dass der Text "6er-Pasch" ausgegeben wird, wenn 2 mal nacheinander eine 6 gewürfelt wurde.
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 47) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 13
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 47) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
Branch analysis from position: 30
Branch analysis from position: 30
filename:       /in/8NHEA
function name:  (null)
number of ops:  35
compiled vars:  !0 = $zaehler, !1 = $zufall1, !2 = $zufall2, !3 = $zufall
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     'Der+Befehl+rand%281%2C6%29+liefert+eine+Zufallszahl+zwischen+1+und+6.%0A+%0AMittels+einer+Schleife+soll+er+sooft+aufgerufen+werden+bis+eine+6+%22gew%C3%BCrfelt%22+wurde.%0ADann+soll+die+Anzahl+der+Schleifendurchg%C3%A4nge+ausgegeben+werden.%0A%3Cbr%3E%0A%3Cbr%3E%0A%3Cbr%3E%0A%3Cbr%3E%0A%0A'
   11     1        ASSIGN                                                   !0, 1
   12     2        INIT_FCALL                                               'rand'
          3        SEND_VAL                                                 1
          4        SEND_VAL                                                 6
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !1, $5
   13     7        INIT_FCALL                                               'rand'
          8        SEND_VAL                                                 1
          9        SEND_VAL                                                 6
         10        DO_ICALL                                         $7      
         11        ASSIGN                                                   !2, $7
   15    12      > JMP                                                      ->25
   17    13    >   ECHO                                                     !3
   18    14        INIT_FCALL                                               'rand'
         15        SEND_VAL                                                 1
         16        SEND_VAL                                                 6
         17        DO_ICALL                                         $9      
         18        ASSIGN                                                   !3, $9
   19    19        INIT_FCALL                                               'rand'
         20        SEND_VAL                                                 1
         21        SEND_VAL                                                 6
         22        DO_ICALL                                         $11     
         23        ASSIGN                                                   !3, $11
   20    24        PRE_INC                                                  !0
   15    25    >   IS_NOT_EQUAL                                     ~14     !1, 6
         26      > JMPNZ_EX                                         ~14     ~14, ->30
         27    >   FETCH_CONSTANT                                   ~15     'zufall2'
         28        IS_NOT_EQUAL                                     ~16     ~15, 6
         29        BOOL                                             ~14     ~16
         30    > > JMPNZ                                                    ~14, ->13
   22    31    >   CONCAT                                           ~17     '%3Cp%3EAnzahl+der+W%C3%BCrfe%3A', !0
         32        ECHO                                                     ~17
   25    33        ECHO                                                     'Die+%C3%9Cbung+soll+so+erg%C3%A4nzt+werden%2C+dass+der+Text+%226er-Pasch%22+ausgegeben+wird%2C+%0Awenn+2+mal+nacheinander+eine+6+gew%C3%BCrfelt+wurde.'
   26    34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.26 ms | 1400 KiB | 15 Q