Php-implemented online game example with scissors

Source: Internet
Author: User

Php-implemented online game example with scissors

This article describes the php-implemented online game with a stone scissors. We will share this with you for your reference. The details are as follows:

<? Php/** Created on **/if (isset ($ _ POST ['sub']) {$ what = $ _ POST ['wh']; // The array to be Input $ my_array = array ("Scissors", "Stone", "cloth"); // The winning rule $ guize = array ("Scissors ", "cloth"), array ("cloth", "Stone"), array ("Stone", "Scissors ")); // obtain the random value $ rand_keys = array_rand ($ my_array); $ computer = $ my_array [$ rand_keys]; echo "your ". $ what. "". $ computer. "<br/>"; $ input = array ($ computer, $ what); // constructs an array of the randomly generated values of the input and the computer, then, we can judge that I is not in the winning rule. F (! (In_array ($ what, $ my_array) {echo "Please input scissors, stones, cloth"; header ("location: index. php ");} if ($ computer = $ what) {echo" Oh, flat ";} elseif (in_array ($ input, $ guize )) {echo "Computer wins";} else {echo "You win ~ ";}}?> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

Run the following command:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.