網頁隨機剪刀石頭布

猜拳的結果: 我輸了

電腦出拳:
我出拳:
<?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 = "平手了";
	}
?>