結果:輸了
<?php include("include/function.php"); $usern = $_GET['usern']; if ($usern == 1){ //設定檔名 $users = "scissors.png"; } if ($usern == 2){ $users = "rock.png"; } if ($usern == 3){ $users = "paper.png"; } $handm = rand(1,3); //取得亂數 if ($handm == 1){ //設定檔名 $hand = "scissors.png"; } if ($handm == 2){ $hand = "rock.png"; } if ($handm == 3){ $hand = "paper.png"; } if ($usern == 1){ if($handm == 1)$msg = "平手"; if($handm == 2)$msg = "輸了"; if($handm == 3)$msg = "贏了"; }else if ($usern == 2){ if($handm == 1)$msg = "贏了"; if($handm == 2)$msg = "平手"; if($handm == 3)$msg = "輸了"; }else if($usern == 3){ if($handm == 1)$msg = "輸了"; if($handm == 2)$msg = "贏了"; if($handm == 3)$msg = "平手"; } ?> <img src="images/<?php echo $hand; ?>" /> // 使用檔案