【发布时间】:2016-04-13 16:26:17
【问题描述】:
我做了一个抛硬币游戏。它由三行组成。我想要翻转数字和硬币。除了翻转的名称(正面,反面)之外,我什么都有,我只得到我为翻转设置的数字。我如何让翻转说出 0 的“正面”或 1 而不是 0 或 1 的“反面”这个词。我试图在回声中做到这一点,但我仍然收到了数字。这是我的代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="keywords" content="insert, keywords, here">
<meta name="description" content="Insert description here">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Coin</title>
</head>
<body>
<header>
<h1> Coin</h1>
</header>
<nav>
</nav>
<section>
<h2> Coin</h2>
<?php
echo "<table>";
echo "<thead>";
echo "<tr>";
echo "</tr>";
echo "<thead>";
echo "<tbody>";
for($i=0; $i<20; $i++){
//0 is heads
//1 is tails
$result = rand(0, 1);
$count = $i+1;
echo "<tr>";
echo "<td>". $count . "</td>";
echo "<td>" . $result . "</td>";
if($result == 0){
echo "<td><img src=\"heads.jpg\" alt=\"heads\"></td>";
} else {
echo "<td><img src=\"tails.jpg\" alt=\"tails\"></td>";
}
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?>
</section>
</body>
</html>
【问题讨论】:
标签: php