豆包AI编程
智能代码生成与优化,高效提升开发速度与质量!
在看了开源中国的网友发布的shell版,于是乎也企图小试牛刀。有不足的地方希望各位不吝啬知道 无 html meta http-equiv="content-type" content="text/html" / head title猜情寻/title /head body form method="post" action="play.php" div align="center"剪
在看了开源中国的网友发布的shell版,于是乎也企图小试牛刀。有不足的地方希望各位不吝啬知道
<meta http-equiv="content-type" content="text/html"><title>猜情寻</title>
<?php if (isset($_POST['sub'])) { $what = $_POST['what']; //需要输入的数组 $my_array = array("剪刀","石头","布"); //获胜规则 $guize = array(array("剪刀","布"),array("布","石头"),array("石头","剪刀")); //取数组中的随机值 $rand_keys = array_rand($my_array); $computer = $my_array[$rand_keys]; echo $computer. "\n"; $input = array($computer,$what); //将输入的what和电脑随机产生的值构造成一个数组,再判断在不在获胜规则中 if (!(in_array($what,$my_array))) { echo "请输入 剪刀、石头、布"; header("location:index.php"); } if ($computer == $what) { echo "噢,平手"; }elseif (in_array($input,$guize)) { echo "电脑胜"; }else { echo "你赢咯~"; } } ?>
php免费学习视频:立即学习
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!
已抢7204个
抢已抢94855个
抢已抢14826个
抢已抢52068个
抢已抢194763个
抢已抢87280个
抢