Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions hangman/backend/game.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php
session_start(); //Start session for user
$words = [ "balloon",
"rifle",
"elephant",
"internet",
"python",
"board",
"github",
"bangladesh"
]; //Word List

$cURLConnection = curl_init(); //Initialize a new session and return a cURL handle.

curl_setopt($cURLConnection, CURLOPT_URL, 'https://random-word-api.herokuapp.com/word?number=1'); //Pass URL as a parameter. This is the target server website address.

curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, 1); //Return the transfer as a string of the return value of curl_exec() instead of outputting it directly.

$wordList = curl_exec($cURLConnection); //Execute the predefined CURL session.

curl_close($cURLConnection); //Close curl resource to free up system resources.

$words = json_decode($wordList); //Convert it to PHP array from JSON format.


if(!isset($_GET['check'])){ //Check if a get variable is set.\
Expand Down