Created
October 25, 2013 02:31
-
-
Save panfeng/7148628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link type='text/css' rel='stylesheet' href='style.css'/> | |
<title>More Coin Flips</title> | |
</head> | |
<body> | |
<p>We will keep flipping a coin as long as the result is heads!</p> | |
<?php | |
$flipCount = 0; | |
do { | |
$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> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.coin { | |
height: 50px; | |
width: 50px; | |
border-radius: 25px; | |
background-color: grey; | |
text-align: center; | |
font-weight: bold; | |
font-family: sans-serif; | |
color: white; | |
margin: 10px; | |
display: inline-block; | |
line-height: 50px; | |
font-size: 20px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment