猜拳的結果: 我贏了!!!!!!
<?php include("include/function.php"); // 取得使用者的拳法 $usern = $_GET['usern']; // echo $usern; if ( $usern == 1 ) { $userh = "scissors.png"; } elseif ( $usern == 2 ) { $userh = "rock.png"; } else { $userh = "paper.png"; } //echo $userh; // 1. 取得亂數 $handn = rand(1,3); // echo $handn; // 2. 設定檔名 if ( $handn == 1 ) { $hand = "scissors.png"; } elseif ( $handn == 2 ) { $hand = "rock.png"; } else { $hand = "paper.png"; } // echo $hand; if ( $usern == 1 ) { if ( $handn == 1 ) $msg = "平手了"; if ( $handn == 2 ) $msg = "我輸了"; if ( $handn == 3 ) $msg = "我贏了!!!!!!"; } elseif ( $usern == 2 ) { if ( $handn == 1 ) $msg = "我贏了!!!!!!"; if ( $handn == 2 ) $msg = "平手了"; if ( $handn == 3 ) $msg = "我輸了"; } else { if ( $handn == 1 ) $msg = "我輸了"; if ( $handn == 2 ) $msg = "我贏了!!!!!!"; if ( $handn == 3 ) $msg = "平手了"; } ?> <p>猜拳的結果: <?php echo $msg; ?></p> <div class="rand"> 電腦出拳: <br/> <img src="images/<?php echo $hand; ?>"/>> </div> <div class="rand"> 我出拳: <br/> <img src="images/<?php echo $userh; ?>"/>> </div>