Php word guessing game, php word guessing _ PHP Tutorial

Source: Internet
Author: User
Php word guessing game, php word guessing. Php word guessing game, php words can be directly copied locally to run phpsession_start (); header (Content-type: texthtml; charsetutf -); $ url $ _ SERVER [HTTP_HOST] $ _ SERVER [php word guessing game, php word guessing

Copy the local file and run it.

<? Phpsession_start (); header ("Content-type: text/html; charset = utf-"); $ url = 'http: // '$ _ SERVER ['http _ host'] $ _ SERVER ['php _ SELF']; function get_word () {$ wordtext = "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the foll Owing disclaimer Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclawing in the documentation and/or other materials provided with the distribution Neither the name of Yii Software LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permissio N this software is provided by the copyright holders and contributors as is and any express or implied warranties, INCLUDING, but not limited, the implied warranties of merchantability and fitness for a special purpose are disclaimed in no event shall the copyright owner or contributors be liable for any direct, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, or consequential damages (INCLUDING, B Ut not limited to, procurement of substitute goods or services; loss of use, DATA, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage "; $ words = preg_split ("/[\ s,] +/", $ wordtext); do {$ I = Rand (, count ($ words)-); $ word = strtoupper ($ words [$ I]);} while (strlen ($ word) <|! Ctype_alpha ($ word); return $ word;} function guess ($ word) {return str_repeat ('_', strlen ($ word);} function output ($ word) {$ str = ''; for ($ I =; $ I
 
  
Script function Ajax (recvType) {var aj = new Object (); ajrecvType = recvType? RecvTypetoUpperCase (): 'html'; ajtargetUrl = ''; ajsendString =''; ajresultHandle = null; ajcreateXMLHttpRequest = function () {var xmlHttp = false; if (windowXMLHttpRequest) {xmlHttp = new XMLHttpRequest ();} else if (windowActiveXObject) {try {xmlHttp = new ActiveXObject ("MsxmlXMLHTTP");} catch (error) {try {xmlHttp = new ActiveXobject ("MicrosoftXMLHttp") ;}catch (error) {xmlHttp = false ;}} return xmlHttp ;} ajXMLHttpReques T = ajcreateXMLHttpRequest (); ajprocessHandle = function () {if (ajXMLHttpRequestreadyState =) {if (ajXMLHttpRequeststatus =) {if (ajrecvType = "HTML ") {ajresultHandle (signature);} else if (ajrecvType = "XML") {ajresultHandle (signature) ;}}} ajget = function (targetUrl, resultHandle) {ajtargetUrl = targetUrl; if (resultHandle! = Null) {response = ajprocessHandle; ajresultHandle = resultHandle;} if (windowXMLHttpRequest) {ajXMLHttpRequestopen ("get", ajtargetUrl); ajXMLHttpRequestsend (null );} else {ajXMLHttpRequestopen ("get", ajtargetUrl, true); ajXMLHttpRequestsend () ;}return aj ;} script var ajax = Ajax (); function select (v) {documentgetElementById (v) styledisplay = 'none'; ajaxget ("guessphp? Op = ajax & k = "+ v, function (r) {var t = rsplit (" | "); documentgetElementById ('word') innerHTML = t []; if (t [] =) {documentgetElementById ('select') styledisplay = 'none'; documentgetElementById ('result') innerHTML = 'success ';} else if (t [] =) {documentgetElementById ('select') styledisplay = 'none'; documentgetElementById ('result') innerHTML = 'failed ';}});} function check (v) {ajaxget ("guessphp? Op = start & k = "+ v, function (r) {windowlocationhref =" <? Php echo $ url;?> ";}) ;}Script <? Phpif (! Isset ($ _ SESSION ['num']) {echo'
  Easy: wrong
  
'; Echo' Normal: wrong
'; Echo' Hard: wrong
';} Else {// echo $ word; echo "you can guess at most" $ _ SESSION ['num'] "times"; echo"
"; Echo"

"; Echo output ($ guess_word); echo"

"; Echo'
'; Echo'

'; For ($ I = ord ('A'); $ I <= ord ('Z'); ++ $ I) {echo "\ n "; $ letter = chr ($ I); echo ''' $ letter ''';} echo'

'; Echo'
'; Echo'
'; Echo'

'; Echo'
'; Echo'
'; Echo 'restart';}?>

This is a php-based word-guessing game. I hope you can draw a line from each other to implement other games and be familiar with php programming.

You can directly copy phpsession_start (); header ("Content-type: text/html; charset = utf-"); $ url = 'http: // '$ _ SERVER ['http _ host'] $ _ SERVER [...

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.