Jump to content

Recommended Posts

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 :(

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.