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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -