PHP Game of Nim problem....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HYPNOTICgoat
Forum Newbie
Posts: 1
Joined: Sat Nov 22, 2008 8:52 pm

PHP Game of Nim problem....

Post by HYPNOTICgoat »

I'll right I have this project for my Orginization of Programming languages and the whole point is to learn a new language we don't know and then explain a bunch of its features to our class mates. So i thought PHP! now part of this project is to create a fairly simple program and use that to explain it to the class...now ive been searching for soooo long and i can not find out how to get user input....as of now the only way ive been able to get it to work is using some html code along with it....but the submit button isn't working very well....i understand the logic but i need some help getting this input figured out....i would prefer console output but it has to work on a windows machine.....so heres what i have so far....I'm also curious if php allows classes like in java and if so could someone give me a link to how this works i looked for quite a while and found some stuff but it only seemed to be for error checking....


here's what i have right now..im using roadsend Compiler...the newest realease...Roadsend PHP is compatible with PHP 5.2.x (ZendEngine 2.x).

while($takeFromPile == 0)
{
echo "Remaining in pile: ";
echo $pile1;
?>
<form action="hahahahah.php" method="post">
How many would you like to take: <input type="text" name="num" />
<input type="submit" />
</form>
<?php
$takeFromPile2 = $_GET["num"];
if($takeFromPile2 >= $pile/2)
echo "Please insert a value less than or equal to half the remaining pile";
else
{
$takeFromPile = $takeFromPile2;
$pile1 = $pile1 - $takeFromPile;
}
}
thanks in advance...
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: PHP Game of Nim problem....

Post by josh »

First of all PHP is a scripting language. If you need to do a speach about it, I'd learn the basics ( walk before you try to run ). In case you didn't know its a web scripting language, it originally was an apache module meaning input comes from HTML forms or from paramaterized URIs in the request and output is in the form of HTML sent to the user's browser. At http://www.php.net you can get a CLI executable for your platform to run the scripts in the console. The same script can run cross platform, it just needs the CLI for the given platform ( PHP supports windows mac and linux ).

http://www.php.net/docs.php
http://us.php.net/FAQ.php <<< I would definitely read this unless you want to fail your project :lol:
Post Reply