1. Home
  2. Computing & Technology
  3. PHP / MySQL

Guess The Number Tutorial

By , About.com Guide

1 of 3

Defining X

<?php
//Starts our php document
if (!$x)
//if we have already defined x and started the game, this does not run
{
Echo "Please Choose a Number 1-100 <p>";
//gives the user instructions
$x = rand (1,100) ;
//creates x
}
What this code does, is check to see if the game has already started. If it has, all of this is ignored. If it has not, then it randomly chooses a number to be the winning number, $x. It also prints some brief instructions for the user.
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. Guess The Number - Number Guessing Tutorial - PHP Guess Number

©2009 About.com, a part of The New York Times Company.

All rights reserved.