Skip to content

Instantly share code, notes, and snippets.

@jasny
Forked from happy-box/magic_8_ball.py
Last active October 22, 2025 22:48
Show Gist options
  • Select an option

  • Save jasny/67d772d452bb230b85ee6088a1ae0ed1 to your computer and use it in GitHub Desktop.

Select an option

Save jasny/67d772d452bb230b85ee6088a1ae0ed1 to your computer and use it in GitHub Desktop.
Simple magic 8-ball game written in PHP
#!/usr/bin/env php
<?php
/**
* Magic 8 Ball IRC bot
* Created by Lance Brignoni
* Converted to PHP by Arnold Daniels
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// Following function asks user question, then returns random results from responses
function answerQuery()
{
$responses = ["Not so sure", "42", "Most likely", "Absolutely not", "Outlook is good",
"I see good things happening", "Never", "Negative", "Could be", "Unclear, ask again",
"Yes", "No", "Possible, but not probable"];
echo "Ask and you shall receive: ";
$question = fgets(STDIN);
echo "Let me dig deep into the waters of life, and find your answer\n";
sleep(2);
echo "Hmmm\n";
sleep(2);
$picked = array_rand($responses);
echo $responses[$picked], "\n";
}
do {
answerQuery();
// Following asks user if they would like to play again, and loops until user is finished
echo "Would you like to ask the Wise One another question? Y/N: ";
$secondQuestion = fgetc(STDIN);
echo "\n";
} while (strtoupper($secondQuestion) === "Y");
@Kerniol1
Copy link

Po wizycie na festiwalu jedzenia chciałem się zrelaksować w domu. Szukałem platformy, która jest bezpieczna i ma dobre promocje. Znalazłem polską stronę, spin macho, która mi się spodobała. Ta platforma z Polski oferuje wiele możliwości, z bonusami powitalnymi i stałymi nagrodami dla aktywnych. Oferty często się zmieniają, a wszystko jest po polsku, co jest super dla Polaków. Spodobało mi się, bo mogłem się bawić bez obaw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment