PHP
I still need to do some homework, but since I’ve been working all day I thought I’d do something that I enjoy
Anyways, today I learned about several PHP loops (most of which I already knew), and my program focuses on a loop I did not know before, the switch-case loop. It is basically like an if-else loop, only that it is easier to write. Personally, I like it!
HTML:
<html> <body> <form action=”scariestCreature.php” method=”post”> What is the scariest fantastical creature? (eg. Werewolf) <br /> <input type=”text” name=”creature” /> <br /> <input type=”submit” value=”Send” /> </form> </body></html>
PHP:
<?php
$creature = $_POST['creature'];
switch($creature){
case ‘werewolf’:
echo ‘Make sure to stock on the silver bullets!’;
break;
case ‘zombie’:
echo ‘Melee weapons never run out of bullets!’;
break;
case ‘vampire’:
echo ‘For honest-to-god Vampires, just use sun.’;
break;
case ‘killer bunny’:
echo ‘Holy Hand Granade!’;
break;
default:
echo ‘I\’m sure it is nothing to be afraid of!’;
}
?>
I still don’t know how to make it possible for the code to actually work
If someone knows, please tell me.
****
On an unrelated note, you have to listen to this song:
leave a comment