PHP Scissors stone cloth Programming ideas, web version

Source: Internet
Author: User
In the open source China's netizens released the shell version, so also tried to try Sledgehammer. There's a shortage of places I hope you don't mean to know.
    1. Guess the feeling of finding
Copy Code
    1. !--? php
    2. if (isset ($_post[' Sub ')) {
    3. $what = $_post[' what ');
    4. //array required for input
    5. $my _array = Array ("Scissors", "stone", "cloth");
    6. //Win rule
    7. $guize = Array ("Scissors", "cloth"), Array ("cloth", "stone"), Array ("Stone", "scissors");
    8. //Take random values in array
    9. $rand _keys = Array_rand ($my _array);
    10. $computer = $my _array[$rand _keys];
    11. Echo $computer. "\ n";
    12. $input = Array ($computer, $what);
    13. //Constructs an array of what is entered and randomly generated by the computer, and then determines that it is not in the winning rule
    14. if (! ( In_array ($what, $my _array)) {
    15. echo "Please enter scissors, stone, cloth";
    16. header ("location:index.php");
    17. }
    18. if ($computer = = $what) {
    19. echo "Oh, tie";
    20. }elseif (In_array ($input, $guize)) {
    21. echo "Computer wins";
    22. }else {
    23. echo "you win ~";
    24. }
    25. }
    26. ;
Copy Code
  • Related Article

    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.