The best cose to ever exist!

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
Hellonagol
Forum Newbie
Posts: 2
Joined: Thu May 03, 2007 3:56 pm

The best cose to ever exist!

Post by Hellonagol »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


The following will save lives and make people millions of dollars

Code: Select all

<?php
function get_input($length = 255) {
	$fr = fopen("php://stdin", "r");
	$input = fgets($fr, $length); 
	$input = rtrim($input);
	fclose($fr);
	return $input;
}
echo "Pikachu attacks!\n";
$pikhealth = 100;
$pikattack = 4;
echo "attack , pokeball , flee\n";
echo "Choose a move: ";
$move = get_input(10);
if ($move == attack){
	echo "Pikachu has Fainted!\n";
}
else if ($move == pokeball){
	echo "You catch the wild Pikachu!\n";
	echo "Give it a name?\n";
	echo "Answer yes or no\n";
	$yesno = get_input(10);
	if ($yesno == yes){
		echo "Enter a name: ";
		$name = get_input(20);
		echo "$name was transfered to box1 in someones pc!\n";
	}
	if ($yesno == no){
		echo "Pikachu was transfered to box1 in someones pc!\n";
	}
	else if ($move == flee){
		echo "You fail to escape!\n";
		echo "Pikachu uses thunderbolt!\n";
		echo "You get killed\n";
	}
}
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hellonagol
Forum Newbie
Posts: 2
Joined: Thu May 03, 2007 3:56 pm

Post by Hellonagol »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Okay that last one is not the best but this is

Code: Select all

<?php
function get_input($length = 255) {
	$fr = fopen("php://stdin", "r");
	$input = fgets($fr, $length); 
	$input = rtrim($input);
	fclose($fr);
	return $input;
}
echo "Pikachu attacks!\n";
echo "attack , pokeball , flee\n";
echo "Choose a move: ";
$move = get_input(10);
if ($move == attack){
	echo "Pikachu has Fainted!\n";
}
else if ($move == pokeball){
	echo "You catch the wild Pikachu!\n";
	echo "Give it a name?\n";
	echo "Answer yes or no\n";
	$yesno = get_input(10);
	if ($yesno == yes){
		echo "Enter a name: ";
		$name = get_input(20);
		echo "$name was transfered to box1 in someones pc!\n";
	}
	if ($yesno == no){
		echo "Pikachu was transfered to box1 in someones pc!\n";
	}
	}
	else if ($move == flee){
		echo "You fail to escape!\n";
		echo "Pikachu uses thunderbolt!\n";
		echo "You get killed\n";
}
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

I bet Nintendo are really worried. This game could ruin them.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

How is the first snippet different to the second one?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

The indentation is a bit wonky. I don't know how you could possible call this the "Best cose" ;-)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I used a Wii controller to press the keys on the keyboard to type my answers into a terminal window -- and it really felt like I was fighting Pikachu!

Best cose of all times!
(#10850)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I was just thinking that I needed some best cose to ever exist.
Post Reply