php - can anyone explain how does $flipCount work? -
i have trouble understanding following recursive code:
<!doctype html> <html> <head> <link type='text/css' rel='stylesheet' href='style.css'/> <title>more coin flips</title> </head> <body> <p>we keep flipping coin long result heads!</p> <?php $flipcount = 0; { $flip = rand(0,1); $flipcount ++; if ($flip){ echo "<div class=\"coin\">h</div>"; } else { echo "<div class=\"coin\">t</div>"; } } while ($flip); $verb = "were"; $last = "flips"; if ($flipcount == 1) { $verb = "was"; $last = "flip"; } echo "<p>there {$verb} {$flipcount} {$last}!</p>"; ?> </body>enter code here </html>
how $flipcount
gets number of $flip
? don't understand how, explain it?
euh... because of $flipcount ++
, equivalent $flipcount = $flipcount +1
?
Comments
Post a Comment