Last active
January 29, 2017 23:00
-
-
Save LandonPowell/6292e699e25d72d61e737a4001220adb to your computer and use it in GitHub Desktop.
THE MOTHER OF ALL PHP PROGRAMS. TRULY A HORRIFYING SITE TO BEHOLD!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
One script to rule them all. | |
*/ | |
/* Simple FizzBuzz */ | |
for ($x = 1; $x <= 100; $x++) { | |
if ($x%3 == 0) echo "Fizz"; | |
if ($x%5 == 0) echo "Buzz"; | |
else if ($x%3) echo $x; | |
echo "<br>\n"; | |
} | |
echo "\n<br><br>\n"; | |
/* | |
Recursive 99 bottles of beer on the wall. | |
The function argument gets one taken down and then it gets passed around. | |
*/ | |
function beerOnTheWall($bottleCount) { | |
if ($bottleCount == 1) return | |
"1 bottle of beer on the wall, 1 bottle of beer. <br>\n". | |
"Take one down, pass it around, no more bottles of beer on the wall.<br>\n"; | |
return | |
"$bottleCount bottles of beer on the wall, $bottleCount bottles of beer. <br>\n". | |
"Take one down, pass it around, ".($bottleCount-1)." bottles of beer on the wall. <br>\n". | |
beerOnTheWall( $bottleCount-1 ); | |
} | |
echo beerOnTheWall(99); | |
echo "\n<br><br>\n"; | |
/* Horrifyingly Procedural Fibonacci. */ | |
$limit = 10; | |
$arr = [0, 1, 0]; | |
for ($x = 2; $x <= $limit+1; $x++) { | |
echo $arr[1] . "<br>\n"; | |
$arr[0] = $arr[1]; | |
$arr[1] += $arr[2]; | |
$arr[2] = $arr[0]; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment