KyZu Posted April 30, 2011 Share Posted April 30, 2011 So I started learning PHP a few days ago and I sort of dived right in trying to make things, this was my first program (a simple BMI calculator) http://pastebin.com/SHfA4pt5 Okay but now I wanted to make hangman, and I'm just...so lost, like, I don't even know how to go about it. Here is the code I have so far (some of it commented out because it was just "ideas" I had). Here is what I have so far: http://pastebin.com/FyQPmR8U So can somebody give me some direction? Is there anything I wrote that is REALLY dumb and unnecessary? Basically I'm trying to find a way to: - log the guesses (how can I do this if I don't have an array, or nothing to put the values in...do I need to duplicate anything?) - check to see if a guess has already been made - replace the underscores with the letter corresponding to that position. and hell I don't even know what else, just trying to get it to work Quote Link to comment https://forums.phpfreaks.com/topic/235227-getting-really-frustrated-making-this-hangman-type-game/ Share on other sites More sharing options...
ignace Posted May 1, 2011 Share Posted May 1, 2011 You need to store it using sessions, so the value persists for the duration of the game. session_start(); // MUST be at the top of your script if(!isset($_SESSION['increment'])) $_SESSION['increment'] = 1; echo $_SESSION['increment']++; If you run this script you'll see the value increment every time you refresh the page. The value of 'increment' is persisted between requests. Quote Link to comment https://forums.phpfreaks.com/topic/235227-getting-really-frustrated-making-this-hangman-type-game/#findComment-1208954 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.