index.php ページの途中に次のような HTML があります。
<form action="" method="post"><input type="submit" value="Reset Game" class="reset-button" title="Admitting defeat?"></form>
私のページの上部に、次のチェックがあります。
if (isset($_POST["submit"]) {
if ($_POST["submit"] === "Reset Game"] {
$_SESSION["word"] = generate_word("dictionary.txt");
$_SESSION["word-progress"] = turn_to_underscores($_SESSION["word"]);
}
}
これにより、ハングマン ゲームの単語と下線付きのバージョンが生成されます。これらの関数は次のとおりです。
/**
* Generate a random word from the given dictionary file
* @param $filename Name of the dictionary file
* @return Random word
*/
function generate_word($filename) {
$dictionary_file = new SplFileObject($filename);
$dictionary_file->seek(rand(0, 80367));
return trim($dictionary_file->current());
}
/**
* Accepts a word and returns it as underscores for obfuscation
* @param $word A given word
* @return Returns the word as underscores
*/
function turn_to_underscores($word) {
$underscored_word = "";
for ($i = 0; $i < strlen($word); $i++) {
$underscored_word .= "_";
}
return $underscored_word;
}
私は電話で持ってきrequire "functions.php";
ます。
私は正確に何を間違っていますか?