-5

投稿に複数の回答を含めるにはどうすればよいですか? また、大文字を区別しないようにする方法を理解できれば、それも役に立ちます。

次に例を示します。

$a = "What is the color of the sky?"

if($_POST['ans'] == "blue")  {
   echo "Correct!";
}

形:

<form method="POST" action="">
<input type="text" name="ans" /><br />
<input type="submit" />
</form>

私が試してみました

if($_POST['ans'] == "blue" . "Blue")  {
   echo "Correct!";
}

if($_POST['ans'] == "blue" or "Blue")  {
       echo "Correct!";
}
4

2 に答える 2

0

すべての文字列を小文字に変換するstrtolowerを使用できるため、bLuE は青色になります

<?php
    if (strtolower($_POST['ans'] == 'blue')) {
        echo 'Correct!';
    }
?>
于 2013-11-05T01:06:02.673 に答える