我正在尝试以不区分大小写的方式查找 "Username" 或 "Password" 的不同变体,如下所示:
$unVar1 = "username";
$unVar2 = "user name";
$usernameVariations1 = strcasecmp($unVar1, $unVar2);
$unVar3 = "User";
$unVar4 = "id";
$usernameVariations2 = strcasecmp($unVar3, $unVar4);
$pwVar1 = "password";
$pwVar2 = "pass";
$passwordVariations1 = strcasecmp($pwVar1, $pwVar2);
if ($element->value === $usernameVariations1
|| $element->value === $usernameVariations2
|| $element->value === $passwordVariations1) {
echo "Weee!";
}
else {
echo "boo!";
}
问题是它为输出boo
中的每个元素输出“” foreach()
。我究竟做错了什么?是否可以将所有这些值放在一个数组中?谢谢。